gitlab.rb 893 Bytes
Newer Older
1
require_dependency 'gitlab/popen'
2 3

module Gitlab
4 5 6 7
  def self.root
    Pathname.new(File.expand_path('..', __dir__))
  end

8 9 10 11
  def self.config
    Settings
  end

Rémy Coutable's avatar
Rémy Coutable committed
12 13 14 15
  COM_URL = 'https://gitlab.com'.freeze
  APP_DIRS_PATTERN = %r{^/?(app|config|ee|lib|spec|\(\w*\))}
  SUBDOMAIN_REGEX = %r{\Ahttps://[a-z0-9]+\.gitlab\.com\z}
  VERSION = File.read(root.join("VERSION")).strip.freeze
16
  REVISION = Gitlab::Popen.popen(%W(#{config.git.bin_path} log --pretty=format:%h -n 1)).first.chomp.freeze
Rémy Coutable's avatar
Rémy Coutable committed
17

Robert Speicher's avatar
Robert Speicher committed
18
  def self.com?
19 20
    # Check `gl_subdomain?` as well to keep parity with gitlab.com
    Gitlab.config.gitlab.url == COM_URL || gl_subdomain?
21 22
  end

23 24 25 26
  def self.org?
    Gitlab.config.gitlab.url == 'https://dev.gitlab.org'
  end

27 28
  def self.gl_subdomain?
    SUBDOMAIN_REGEX === Gitlab.config.gitlab.url
Robert Speicher's avatar
Robert Speicher committed
29
  end
30

31
  def self.dev_env_or_com?
32
    Rails.env.test? || Rails.env.development? || org? || com?
33
  end
34
end