scm: git: add new method 'scm_cmd' to wrap shellout.
Refer Mercurial adapter r4830. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4886 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
915107a0ec
commit
1c5cd49cd2
|
@ -24,6 +24,9 @@ module Redmine
|
|||
# Git executable name
|
||||
GIT_BIN = Redmine::Configuration['scm_git_command'] || "git"
|
||||
|
||||
# raised if scm command exited with error, e.g. unknown revision.
|
||||
class ScmCommandAborted < CommandFailed; end
|
||||
|
||||
class << self
|
||||
def client_command
|
||||
@@bin ||= GIT_BIN
|
||||
|
@ -300,6 +303,19 @@ module Redmine
|
|||
identifier[0,8]
|
||||
end
|
||||
end
|
||||
|
||||
def scm_cmd(*args, &block)
|
||||
repo_path = root_url || url
|
||||
full_args = [GIT_BIN, '--git-dir', repo_path]
|
||||
full_args += args
|
||||
full_args << '--no-color'
|
||||
ret = shellout(full_args.map { |e| shell_quote e.to_s }.join(' '), &block)
|
||||
if $? && $?.exitstatus != 0
|
||||
raise ScmCommandAborted, "git exited with non-zero status: #{$?.exitstatus}"
|
||||
end
|
||||
ret
|
||||
end
|
||||
private :scm_cmd
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue