summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-02-28 14:12:24 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-02-28 14:12:24 +0000
commit06c9eea67a802c0039f7ff40de28db16cb1e5893 (patch)
treeab5752a249e43f66706306cd137d7a5706776714 /lib
parent06f078a8137a532e638274abc89d5a06654865e1 (diff)
downloadredmine-06c9eea67a802c0039f7ff40de28db16cb1e5893.tar.gz
redmine-06c9eea67a802c0039f7ff40de28db16cb1e5893.zip
scm: git: refactor lastrev() in adapter.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4963 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/scm/adapters/git_adapter.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 7e1f20bbe..4d3ea598f 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -127,14 +127,13 @@ module Redmine
entries.sort_by_name
end
- def lastrev(path,rev)
+ def lastrev(path, rev)
return nil if path.nil?
- cmd = "#{self.class.sq_bin} --git-dir #{target('')} log --no-color --date=iso --pretty=fuller --no-merges -n 1 "
- cmd << " #{shell_quote rev} " if rev
- cmd << "-- #{shell_quote path} " unless path.empty?
+ cmd_args = %w|log --no-color --date=iso --pretty=fuller --no-merges -n 1|
+ cmd_args << rev if rev
+ cmd_args << "--" << path unless path.empty?
lines = []
- shellout(cmd) { |io| lines = io.readlines }
- return nil if $? && $?.exitstatus != 0
+ scm_cmd(*cmd_args) { |io| lines = io.readlines }
begin
id = lines[0].split[1]
author = lines[1].match('Author:\s+(.*)$')[1]
@@ -147,11 +146,13 @@ module Redmine
:time => time,
:message => nil,
:paths => nil
- })
+ })
rescue NoMethodError => e
logger.error("The revision '#{path}' has a wrong format")
return nil
end
+ rescue ScmCommandAborted
+ nil
end
def revisions(path, identifier_from, identifier_to, options={})
@@ -165,7 +166,7 @@ module Redmine
from_to << "#{identifier_to}" if identifier_to
cmd_args << from_to if !from_to.empty?
cmd_args << "--since=#{options[:since].strftime("%Y-%m-%d %H:%M:%S")}" if options[:since]
- cmd_args << "--" << "#{path}" if path && !path.empty?
+ cmd_args << "--" << path if path && !path.empty?
scm_cmd *cmd_args do |io|
files=[]