diff options
Diffstat (limited to 'lib/helpers/generic.rb')
-rw-r--r-- | lib/helpers/generic.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb index 09c03e80..564118e8 100644 --- a/lib/helpers/generic.rb +++ b/lib/helpers/generic.rb @@ -9,8 +9,33 @@ module Nanoc::Helpers ENV['NANOC_ENV'] == 'production' end + # + # Check if NANOC_ENV is set to production and the branch is the default one. + # For things that should only be built in production of the default branch. + # Sometimes we don't want things to be deployed into the stable branches, + # which they are considered production. + # + def production_and_default_branch? + ENV['NANOC_ENV'] == 'production' && ENV['CI_DEFAULT_BRANCH'] == ENV['CI_COMMIT_REF_NAME'] + end + + # + # Used when bundling gitlab-docs with Omnibus + # 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 |