scm: fix diffs do not handle one line new files properly (#7618).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4929 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7dfd0bf679
commit
35f075d8ad
|
@ -36,7 +36,7 @@ module Redmine
|
||||||
end
|
end
|
||||||
unless diff_table.add_line line
|
unless diff_table.add_line line
|
||||||
line.force_encoding(line_encoding) if line_encoding
|
line.force_encoding(line_encoding) if line_encoding
|
||||||
self << diff_table if diff_table.length > 1
|
self << diff_table if diff_table.length > 0
|
||||||
diff_table = DiffTable.new(diff_type)
|
diff_table = DiffTable.new(diff_type)
|
||||||
end
|
end
|
||||||
lines += 1
|
lines += 1
|
||||||
|
|
|
@ -60,8 +60,39 @@ DIFF
|
||||||
assert_equal 1, diff.size
|
assert_equal 1, diff.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_one_line_new_files
|
||||||
|
diff = Redmine::UnifiedDiff.new(<<-DIFF
|
||||||
|
diff -r 000000000000 -r ea98b14f75f0 README1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/README1
|
||||||
|
@@ -0,0 +1,1 @@
|
||||||
|
+test1
|
||||||
|
diff -r 000000000000 -r ea98b14f75f0 README2
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/README2
|
||||||
|
@@ -0,0 +1,1 @@
|
||||||
|
+test2
|
||||||
|
diff -r 000000000000 -r ea98b14f75f0 README3
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/README3
|
||||||
|
@@ -0,0 +1,3 @@
|
||||||
|
+test4
|
||||||
|
+test5
|
||||||
|
+test6
|
||||||
|
diff -r 000000000000 -r ea98b14f75f0 README4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/README4
|
||||||
|
@@ -0,0 +1,3 @@
|
||||||
|
+test4
|
||||||
|
+test5
|
||||||
|
+test6
|
||||||
|
DIFF
|
||||||
|
)
|
||||||
|
assert_equal 4, diff.size
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def read_diff_fixture(filename)
|
def read_diff_fixture(filename)
|
||||||
File.new(File.join(File.dirname(__FILE__), '/../../../fixtures/diffs', filename)).read
|
File.new(File.join(File.dirname(__FILE__), '/../../../fixtures/diffs', filename)).read
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue