# So look for diffs of the form ["M", "path"] which are matched by ["A", "path"] and remove them.
if commit.diffs
commit.diffs.delete_if do |d|
- d.action == 'M' && commit.diffs.select { |x| x.action == 'A' and x.path == d.path }.any?
+ d.action =~ /[MR]/ && commit.diffs.select { |x| x.action == 'A' and x.path == d.path }.any?
end
end
commit
assert_equal '/foo', SvnAdapter.new(:branch_name => '/trunk/hamcrest-c++').strip_path_branch('/trunk/hamcrest-c++/foo')
end
- def test_remove_dupes
+ def test_remove_dupes_add_modify
svn = SvnAdapter.new
c = Scm::Commit.new(:diffs => [ Scm::Diff.new(:action => "A", :path => "foo"),
Scm::Diff.new(:action => "M", :path => "foo") ])
assert_equal 'A', c.diffs.first.action
end
+ def test_remove_dupes_add_replace
+ svn = SvnAdapter.new
+ c = Scm::Commit.new(:diffs => [ Scm::Diff.new(:action => "R", :path => "foo"),
+ Scm::Diff.new(:action => "A", :path => "foo") ])
+
+ svn.remove_dupes(c)
+ assert_equal 1, c.diffs.size
+ assert_equal 'A', c.diffs.first.action
+ end
+
# Had so many bugs around this case that a test was required
def test_deepen_commit_with_nil_diffs
with_svn_repository('svn') do |svn|