[#748] Use SCM commands to detect the revision
This commit is contained in:
parent
b2998c3972
commit
611889f3f7
|
@ -38,7 +38,14 @@ module ChiliProject
|
|||
end
|
||||
|
||||
def self.revision
|
||||
`git --git-dir="#{Rails.root.join('.git')}" rev-parse --short=9 HEAD`.chomp if File.directory? Rails.root.join('.git')
|
||||
@revision ||= begin
|
||||
git = Redmine::Scm::Adapters::GitAdapter
|
||||
git_dir = Rails.root.join('.git')
|
||||
|
||||
if File.directory? git_dir
|
||||
git.send(:shellout, "#{git.sq_bin} --git-dir='#{git_dir}' rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
REVISION = self.revision
|
||||
|
|
|
@ -19,10 +19,10 @@ module Redmine
|
|||
module Adapters
|
||||
class GitAdapter < AbstractAdapter
|
||||
|
||||
SCM_GIT_REPORT_LAST_COMMIT = true
|
||||
SCM_GIT_REPORT_LAST_COMMIT = true unless defined?(SCM_GIT_REPORT_LAST_COMMIT)
|
||||
|
||||
# Git executable name
|
||||
GIT_BIN = Redmine::Configuration['scm_git_command'] || "git"
|
||||
GIT_BIN = Redmine::Configuration['scm_git_command'] || "git" unless defined?(GIT_BIN)
|
||||
|
||||
# raised if scm command exited with error, e.g. unknown revision.
|
||||
class ScmCommandAborted < CommandFailed; end
|
||||
|
|
Loading…
Reference in New Issue