diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2021-01-18 15:12:29 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2021-01-18 15:53:28 +0300 |
commit | a968c6dbc843da7f1e7e5d05b9aef93f9686db68 (patch) | |
tree | f0de035c15e3b804f90b0fdf9c5ebd587cdeec80 /lib/helpers/generic.rb | |
parent | f3f2bdf27d687ac9aacc9d44a0ede4769b8a8cc6 (diff) |
Hide survey banner on stable branches
We don't want the banner to be shown on stable branches.
This introduces a new function that checks if CI_COMMIT_REF_NAME
is defined, and if not, it uses Git to find the current branch name.
If show_banner is false and current_branch is not a stable branch,
hide the banner.
Diffstat (limited to 'lib/helpers/generic.rb')
-rw-r--r-- | lib/helpers/generic.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb index 6dfcaf96..264ba497 100644 --- a/lib/helpers/generic.rb +++ b/lib/helpers/generic.rb @@ -25,5 +25,17 @@ module Nanoc::Helpers def omnibus? ENV['NANOC_ENV'] == 'omnibus' end + + # + # Find the current branch. If CI_COMMIT_BRANCH is not defined, that means + # we're working locally, and Git is used to find the branch. + # + def current_branch + if ENV['CI_COMMIT_REF_NAME'].nil? + `git branch --show-current`.tr("\n", '') + else + ENV['CI_COMMIT_REF_NAME'] + end + end end end |