summaryrefslogtreecommitdiff
path: root/lib/gitlab.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-05-25 13:32:49 +0000
committerRémy Coutable <remy@rymai.me>2018-05-25 13:32:49 +0000
commitcc570b6c44b69469ba675e2e66fc14808890201d (patch)
tree93c296567b2503f30223566c44c62f1f6d13feea /lib/gitlab.rb
parentf5e6300b8b916ce6a583b2344b4edb07945fd153 (diff)
parentd50a80a282b2ca145841774f4be154a977cccfd8 (diff)
downloadgitlab-ce-cc570b6c44b69469ba675e2e66fc14808890201d.tar.gz
Merge branch '46600-fix-gitlab-revision-when-not-in-git-repo' into 'master'
Resolve "gitlab 10.8 assumes that installation is a git working copy." Closes #46600 See merge request gitlab-org/gitlab-ce!19125
Diffstat (limited to 'lib/gitlab.rb')
-rw-r--r--lib/gitlab.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index 31119471b8e..a129746e2c6 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -13,11 +13,26 @@ module Gitlab
@_migrations_hash ||= Digest::MD5.hexdigest(ActiveRecord::Migrator.get_all_versions.to_s)
end
+ def self.revision
+ @_revision ||= begin
+ if File.exist?(root.join("REVISION"))
+ File.read(root.join("REVISION")).strip.freeze
+ else
+ result = Gitlab::Popen.popen_with_detail(%W[#{config.git.bin_path} log --pretty=format:%h -n 1])
+
+ if result.status.success?
+ result.stdout.chomp.freeze
+ else
+ "Unknown".freeze
+ end
+ end
+ end
+ end
+
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
- REVISION = Gitlab::Popen.popen(%W(#{config.git.bin_path} log --pretty=format:%h -n 1)).first.chomp.freeze
def self.com?
# Check `gl_subdomain?` as well to keep parity with gitlab.com