scm: git: raise exception if "git log" is error and block is given in lib revision method (#8857)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8837 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-02-10 22:56:54 +00:00
parent c5c8cd43c0
commit d90cdb1b10
3 changed files with 42 additions and 25 deletions

View File

@ -153,6 +153,7 @@ class Repository::Git < Repository
from_scmid = nil
from_scmid = h["branches"][br]["last_scmid"] if h["branches"][br]
h["branches"][br] ||= {}
begin
scm.revisions('', from_scmid, br, {:reverse => true}) do |rev|
db_rev = find_changeset_by_name(rev.revision)
transaction do
@ -169,6 +170,9 @@ class Repository::Git < Repository
self.save
end
end
rescue Redmine::Scm::Adapters::CommandFailed => e
logger.error("save revisions error: #{e.message}")
end
end
end
private :save_revisions

View File

@ -290,9 +290,14 @@ module Redmine
end
revs
rescue ScmCommandAborted => e
logger.error("git log #{from_to.to_s} error: #{e.message}")
err_msg = "git log error: #{e.message}"
logger.error(err_msg)
if block_given?
raise CommandFailed, err_msg
else
revs
end
end
def diff(path, identifier_from, identifier_to=nil)
path ||= ''

View File

@ -191,6 +191,8 @@ begin
end
def test_revisions_invalid_rev
assert_equal [], @adapter.revisions('', '1234abcd', "master")
assert_raise Redmine::Scm::Adapters::CommandFailed do
revs1 = []
@adapter.revisions('',
'1234abcd',
@ -198,7 +200,7 @@ begin
{:reverse => true}) do |rev|
revs1 << rev
end
assert_equal [], revs1
end
end
def test_revisions_includes_master_two_revs
@ -277,6 +279,12 @@ begin
end
def test_revisions_invalid_rev_excludes
assert_equal [],
@adapter.revisions('', nil, nil,
{:reverse => true,
:includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'],
:excludes => ['0123abcd4567']})
assert_raise Redmine::Scm::Adapters::CommandFailed do
revs1 = []
@adapter.revisions('', nil, nil,
{:reverse => true,
@ -284,7 +292,7 @@ begin
:excludes => ['0123abcd4567']}) do |rev|
revs1 << rev
end
assert_equal [], revs1
end
end
def test_getting_revisions_with_spaces_in_filename