scm: git: add includes and excludes options to lib revisions method (#8857)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8815 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-02-08 23:38:35 +00:00
parent adb81b1ff6
commit 34b3a9851f
2 changed files with 67 additions and 3 deletions

View File

@ -193,9 +193,17 @@ module Redmine
cmd_args << "--reverse" if options[:reverse]
cmd_args << "-n" << "#{options[:limit].to_i}" if options[:limit]
from_to = ""
from_to << "#{identifier_from}.." if identifier_from
from_to << "#{identifier_to}" if identifier_to
cmd_args << from_to if !from_to.empty?
if identifier_from || identifier_to
from_to << "#{identifier_from}.." if identifier_from
from_to << "#{identifier_to}" if identifier_to
cmd_args << from_to if !from_to.empty?
else
cmd_args += options[:includes] unless options[:includes].blank?
unless options[:excludes].blank?
cmd_args << "--not"
cmd_args += options[:excludes]
end
end
cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty?
scm_cmd *cmd_args do |io|

View File

@ -193,6 +193,62 @@ begin
assert_equal [], revs1
end
def test_revisions_includes_master_two_revs
revs1 = []
@adapter.revisions('', nil, nil,
{:reverse => true,
:includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'],
:excludes => ['4f26664364207fa8b1af9f8722647ab2d4ac5d43']}) do |rev|
revs1 << rev
end
assert_equal 2, revs1.length
assert_equal 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b', revs1[ 0].identifier
assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier
end
def test_revisions_includes_merged_revs
revs1 = []
@adapter.revisions('', nil, nil,
{:reverse => true,
:includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'],
:excludes => ['fba357b886984ee71185ad2065e65fc0417d9b92']}) do |rev|
revs1 << rev
end
assert_equal 7, revs1.length
assert_equal '7e61ac704deecde634b51e59daa8110435dcb3da', revs1[ 0].identifier
assert_equal '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', revs1[ 1].identifier
assert_equal '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', revs1[ 2].identifier
assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[-1].identifier
end
def test_revisions_includes_two_heads
revs1 = []
@adapter.revisions('', nil, nil,
{:reverse => true,
:includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c',
'1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127'],
:excludes => ['4f26664364207fa8b1af9f8722647ab2d4ac5d43',
'4fc55c43bf3d3dc2efb66145365ddc17639ce81e']}) do |rev|
revs1 << rev
end
assert_equal 4, revs1.length
assert_equal 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b', revs1[ 0].identifier
assert_equal '83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', revs1[ 1].identifier
assert_equal '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', revs1[-2].identifier
assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[-1].identifier
end
def test_revisions_invalid_rev_excludes
revs1 = []
@adapter.revisions('', nil, nil,
{:reverse => true,
:includes => ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'],
:excludes => ['0123abcd4567']}) do |rev|
revs1 << rev
end
assert_equal [], revs1
end
def test_getting_revisions_with_spaces_in_filename
assert_equal 1, @adapter.revisions("filemane with spaces.txt",
nil, "master").length