diff --git a/config/helpers/is_ee_env.js b/config/helpers/is_ee_env.js index 3fe9bb891eb1cdc3640d39d1abb49605c5fc7bfb..801cf6abc819f68e097f57067e67691b145ca7cd 100644 --- a/config/helpers/is_ee_env.js +++ b/config/helpers/is_ee_env.js @@ -3,7 +3,12 @@ const path = require('path'); const ROOT_PATH = path.resolve(__dirname, '../..'); +// The `IS_GITLAB_EE` is always `string` or `nil` +// Thus the nil or empty string will result +// in using default value: true +// +// The behavior needs to be synchronised with +// lib/gitlab.rb: Gitlab.ee? module.exports = - process.env.IS_GITLAB_EE !== undefined - ? JSON.parse(process.env.IS_GITLAB_EE) - : fs.existsSync(path.join(ROOT_PATH, 'ee')); + fs.existsSync(path.join(ROOT_PATH, 'ee', 'app', 'models', 'license.rb')) && + (!process.env.IS_GITLAB_EE || JSON.parse(process.env.IS_GITLAB_EE)); diff --git a/lib/gitlab.rb b/lib/gitlab.rb index b337f5cbf2ccf61c902e334705fee852b9888ed0..0cc9a6a5fb12e396e1c72f9e755bcf4e7e709378 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -65,14 +65,18 @@ def self.dev_env_or_com? def self.ee? @is_ee ||= - if ENV['IS_GITLAB_EE'] && !ENV['IS_GITLAB_EE'].empty? - Gitlab::Utils.to_boolean(ENV['IS_GITLAB_EE']) - else - # We may use this method when the Rails environment is not loaded. This - # means that checking the presence of the License class could result in - # this method returning `false`, even for an EE installation. - root.join('ee/app/models/license.rb').exist? - end + # We use this method when the Rails environment is not loaded. This + # means that checking the presence of the License class could result in + # this method returning `false`, even for an EE installation. + # + # The `IS_GITLAB_EE` is always `string` or `nil` + # Thus the nil or empty string will result + # in using default value: true + # + # The behavior needs to be synchronised with + # config/helpers/is_ee_env.js + root.join('ee/app/models/license.rb').exist? && + (ENV['IS_GITLAB_EE'].to_s.empty? || Gitlab::Utils.to_boolean(ENV['IS_GITLAB_EE'])) end def self.ee