]> source.dussan.org Git - redmine.git/commitdiff
add git format patch to UnifiedDiffTest (#33357)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 5 May 2020 11:55:54 +0000 (11:55 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 5 May 2020 11:55:54 +0000 (11:55 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@19751 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/lib/redmine/unified_diff_test.rb

index 4a1ec662f7b9f23a162934225d2a11403d4139e0..bbe976cdbfe47590fb66a4affa4d75f5e61cb8ac 100644 (file)
@@ -415,6 +415,44 @@ class Redmine::UnifiedDiffTest < ActiveSupport::TestCase
     assert_equal 9, diff[1].size
   end
 
+  def test_git_footer_line
+    raw = <<~DIFF
+      From 1ed13eda266a3e0a5a8624e79ae28874ebcdeb5c Mon Sep 17 00:00:00 2001
+      From: test <none@none>
+      Date: Thu, 30 Apr 2020 11:40:20 +0900
+      Subject: [PATCH] add 'rpm -q git' and its result
+      
+      ---
+       test.txt | 2 ++
+       1 file changed, 2 insertions(+)
+
+      diff --git a/test.txt b/test.txt
+      index 0a406b9..c39ee31 100644
+      --- a/test.txt
+      +++ b/test.txt
+      @@ -6,3 +6,5 @@ $ hg add test.txt
+       $ hg commit -m `echo -e "U+1F603\U1F603"` -u `echo -e "U+1F603\U1F603"`
+       $ hg bookmark master
+       $ hg push ../git_utf8_repository
+      +$ rpm -q git
+      +git-1.8.3.1-21.el7_7.x86_64
+      -- 
+      1.8.3.1
+      
+    DIFF
+    lines = raw.split("\n")
+    lines << ""
+    assert_equal '', lines[-1]
+    body_lines = lines[0..-4]
+    footer_lines = lines[-3..-1]
+    assert_equal '+git-1.8.3.1-21.el7_7.x86_64', body_lines[-1]
+    assert_equal '-- ', footer_lines[0]
+    assert_equal '', footer_lines[-1]
+    diff = Redmine::UnifiedDiff.new(body_lines.join("\n") + "\n", :type => 'sbs')
+    assert_equal 1, diff.size
+    assert_equal 5, diff[0].size
+  end
+
   private
 
   def read_diff_fixture(filename)