Commit 611889f3 authored by Holger Just's avatar Holger Just

[#748] Use SCM commands to detect the revision

parent b2998c39
...@@ -38,7 +38,14 @@ module ChiliProject ...@@ -38,7 +38,14 @@ module ChiliProject
end end
def self.revision 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 end
REVISION = self.revision REVISION = self.revision
......
...@@ -19,10 +19,10 @@ module Redmine ...@@ -19,10 +19,10 @@ module Redmine
module Adapters module Adapters
class GitAdapter < AbstractAdapter 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 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. # raised if scm command exited with error, e.g. unknown revision.
class ScmCommandAborted < CommandFailed; end class ScmCommandAborted < CommandFailed; end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment