Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -88,17 +90,16 @@ class Redmine::UnifiedDiffTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_partials_with_html_entities
|
||||
raw = <<-DIFF
|
||||
--- test.orig.txt Wed Feb 15 16:10:39 2012
|
||||
+++ test.new.txt Wed Feb 15 16:11:25 2012
|
||||
@@ -1,5 +1,5 @@
|
||||
Semicolons were mysteriously appearing in code diffs in the repository
|
||||
|
||||
-void DoSomething(std::auto_ptr<MyClass> myObj)
|
||||
+void DoSomething(const MyClass& myObj)
|
||||
|
||||
DIFF
|
||||
|
||||
raw = <<~DIFF
|
||||
--- test.orig.txt Wed Feb 15 16:10:39 2012
|
||||
+++ test.new.txt Wed Feb 15 16:11:25 2012
|
||||
@@ -1,5 +1,5 @@
|
||||
Semicolons were mysteriously appearing in code diffs in the repository
|
||||
|
||||
-void DoSomething(std::auto_ptr<MyClass> myObj)
|
||||
+void DoSomething(const MyClass& myObj)
|
||||
|
||||
DIFF
|
||||
diff = Redmine::UnifiedDiff.new(raw, :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 'void DoSomething(<span>std::auto_ptr<MyClass></span> myObj)', diff.first[2].html_line_left
|
||||
|
@ -111,147 +112,187 @@ DIFF
|
|||
end
|
||||
|
||||
def test_line_starting_with_dashes
|
||||
diff = Redmine::UnifiedDiff.new(<<-DIFF
|
||||
--- old.txt Wed Nov 11 14:24:58 2009
|
||||
+++ new.txt Wed Nov 11 14:25:02 2009
|
||||
@@ -1,8 +1,4 @@
|
||||
-Lines that starts with dashes:
|
||||
-
|
||||
-------------------------
|
||||
--- file.c
|
||||
-------------------------
|
||||
+A line that starts with dashes:
|
||||
|
||||
and removed.
|
||||
|
||||
@@ -23,4 +19,4 @@
|
||||
|
||||
|
||||
|
||||
-Another chunk of change
|
||||
+Another chunk of changes
|
||||
diff = Redmine::UnifiedDiff.new(<<~DIFF)
|
||||
--- old.txt Wed Nov 11 14:24:58 2009
|
||||
+++ new.txt Wed Nov 11 14:25:02 2009
|
||||
@@ -1,8 +1,4 @@
|
||||
-Lines that starts with dashes:
|
||||
-
|
||||
-------------------------
|
||||
--- file.c
|
||||
-------------------------
|
||||
+A line that starts with dashes:
|
||||
|
||||
DIFF
|
||||
)
|
||||
and removed.
|
||||
|
||||
@@ -23,4 +19,4 @@
|
||||
|
||||
|
||||
|
||||
-Another chunk of change
|
||||
+Another chunk of changes
|
||||
|
||||
DIFF
|
||||
assert_equal 1, diff.size
|
||||
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
|
||||
)
|
||||
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
|
||||
assert_equal "README1", diff[0].file_name
|
||||
end
|
||||
|
||||
def test_both_git_diff
|
||||
diff = Redmine::UnifiedDiff.new(<<-DIFF
|
||||
# HG changeset patch
|
||||
# User test
|
||||
# Date 1348014182 -32400
|
||||
# Node ID d1c871b8ef113df7f1c56d41e6e3bfbaff976e1f
|
||||
# Parent 180b6605936cdc7909c5f08b59746ec1a7c99b3e
|
||||
modify test1.txt
|
||||
diff = Redmine::UnifiedDiff.new(<<~DIFF)
|
||||
# HG changeset patch
|
||||
# User test
|
||||
# Date 1348014182 -32400
|
||||
# Node ID d1c871b8ef113df7f1c56d41e6e3bfbaff976e1f
|
||||
# Parent 180b6605936cdc7909c5f08b59746ec1a7c99b3e
|
||||
modify test1.txt
|
||||
|
||||
diff -r 180b6605936c -r d1c871b8ef11 test1.txt
|
||||
--- a/test1.txt
|
||||
+++ b/test1.txt
|
||||
@@ -1,1 +1,1 @@
|
||||
-test1
|
||||
+modify test1
|
||||
DIFF
|
||||
)
|
||||
diff -r 180b6605936c -r d1c871b8ef11 test1.txt
|
||||
--- a/test1.txt
|
||||
+++ b/test1.txt
|
||||
@@ -1,1 +1,1 @@
|
||||
-test1
|
||||
+modify test1
|
||||
DIFF
|
||||
assert_equal 1, diff.size
|
||||
assert_equal "test1.txt", diff[0].file_name
|
||||
end
|
||||
|
||||
def test_previous_file_name_with_git
|
||||
diff = Redmine::UnifiedDiff.new(<<~DIFF)
|
||||
From 585da9683fb5ed7bf7cb438492e3347cdf3d83df Mon Sep 17 00:00:00 2001
|
||||
From: Gregor Schmidt <schmidt@nach-vorne.eu>
|
||||
Date: Mon, 5 Mar 2018 14:12:13 +0100
|
||||
Subject: [PATCH] changes including a rename, rename+modify and addition
|
||||
|
||||
---
|
||||
one.markdown => one.md | 0
|
||||
three.md | 2 ++
|
||||
two.markdown => two.md | 1 +
|
||||
3 files changed, 3 insertions(+)
|
||||
rename one.markdown => one.md (100%)
|
||||
create mode 100644 three.md
|
||||
rename two.markdown => two.md (50%)
|
||||
|
||||
diff --git a/one.markdown b/one.md
|
||||
similarity index 100%
|
||||
rename from one.markdown
|
||||
rename to one.md
|
||||
diff --git a/three.md b/three.md
|
||||
new file mode 100644
|
||||
index 0000000..288012f
|
||||
--- /dev/null
|
||||
+++ b/three.md
|
||||
@@ -0,0 +1,2 @@
|
||||
+three
|
||||
+=====
|
||||
diff --git a/two.markdown b/two.md
|
||||
similarity index 50%
|
||||
rename from two.markdown
|
||||
rename to two.md
|
||||
index f719efd..6a268ed 100644
|
||||
--- a/two.markdown
|
||||
+++ b/two.md
|
||||
@@ -1 +1,2 @@
|
||||
two
|
||||
+===
|
||||
--
|
||||
2.14.1
|
||||
DIFF
|
||||
assert_equal 2, diff.size
|
||||
assert_equal "three.md", diff[0].file_name
|
||||
assert_nil diff[0].previous_file_name
|
||||
|
||||
assert_equal "two.md", diff[1].file_name
|
||||
assert_equal "two.markdown", diff[1].previous_file_name
|
||||
end
|
||||
|
||||
def test_include_a_b_slash
|
||||
diff = Redmine::UnifiedDiff.new(<<-DIFF
|
||||
--- test1.txt
|
||||
+++ b/test02.txt
|
||||
@@ -1 +0,0 @@
|
||||
-modify test1
|
||||
DIFF
|
||||
)
|
||||
diff = Redmine::UnifiedDiff.new(<<~DIFF)
|
||||
--- test1.txt
|
||||
+++ b/test02.txt
|
||||
@@ -1 +0,0 @@
|
||||
-modify test1
|
||||
DIFF
|
||||
assert_equal 1, diff.size
|
||||
assert_equal "b/test02.txt", diff[0].file_name
|
||||
|
||||
diff = Redmine::UnifiedDiff.new(<<-DIFF
|
||||
--- a/test1.txt
|
||||
+++ a/test02.txt
|
||||
@@ -1 +0,0 @@
|
||||
-modify test1
|
||||
DIFF
|
||||
)
|
||||
diff = Redmine::UnifiedDiff.new(<<~DIFF)
|
||||
--- a/test1.txt
|
||||
+++ a/test02.txt
|
||||
@@ -1 +0,0 @@
|
||||
-modify test1
|
||||
DIFF
|
||||
assert_equal 1, diff.size
|
||||
assert_equal "a/test02.txt", diff[0].file_name
|
||||
|
||||
diff = Redmine::UnifiedDiff.new(<<-DIFF
|
||||
--- a/test1.txt
|
||||
+++ test02.txt
|
||||
@@ -1 +0,0 @@
|
||||
-modify test1
|
||||
DIFF
|
||||
)
|
||||
diff = Redmine::UnifiedDiff.new(<<~DIFF)
|
||||
--- a/test1.txt
|
||||
+++ test02.txt
|
||||
@@ -1 +0,0 @@
|
||||
-modify test1
|
||||
DIFF
|
||||
assert_equal 1, diff.size
|
||||
assert_equal "test02.txt", diff[0].file_name
|
||||
end
|
||||
|
||||
def test_utf8_ja
|
||||
ja = " text_tip_issue_end_day: "
|
||||
ja += "\xe3\x81\x93\xe3\x81\xae\xe6\x97\xa5\xe3\x81\xab\xe7\xb5\x82\xe4\xba\x86\xe3\x81\x99\xe3\x82\x8b<span>\xe3\x82\xbf\xe3\x82\xb9\xe3\x82\xaf</span>".force_encoding('UTF-8')
|
||||
with_settings :repositories_encodings => '' do
|
||||
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ja.diff'), :type => 'inline')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 12, diff.first.size
|
||||
assert_equal ja, diff.first[4].html_line_left
|
||||
assert_equal ' text_tip_issue_end_day: この日に終了する<span>タスク</span>', diff.first[4].html_line_left
|
||||
end
|
||||
end
|
||||
|
||||
def test_utf8_ru
|
||||
ru = " other: "\xd0\xbe\xd0\xba\xd0\xbe\xd0\xbb\xd0\xbe %{count} \xd1\x87\xd0\xb0\xd1\x81<span>\xd0\xb0</span>"".force_encoding('UTF-8')
|
||||
with_settings :repositories_encodings => '' do
|
||||
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ru.diff'), :type => 'inline')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 8, diff.first.size
|
||||
assert_equal ru, diff.first[3].html_line_left
|
||||
assert_equal ' other: "около %{count} час<span>а</span>"', diff.first[3].html_line_left
|
||||
end
|
||||
end
|
||||
|
||||
def test_offset_range_ascii_1
|
||||
raw = <<-DIFF
|
||||
--- a.txt 2013-04-05 14:19:39.000000000 +0900
|
||||
+++ b.txt 2013-04-05 14:19:51.000000000 +0900
|
||||
@@ -1,3 +1,3 @@
|
||||
aaaa
|
||||
-abc
|
||||
+abcd
|
||||
bbbb
|
||||
DIFF
|
||||
raw = <<~DIFF
|
||||
--- a.txt 2013-04-05 14:19:39.000000000 +0900
|
||||
+++ b.txt 2013-04-05 14:19:51.000000000 +0900
|
||||
@@ -1,3 +1,3 @@
|
||||
aaaa
|
||||
-abc
|
||||
+abcd
|
||||
bbbb
|
||||
DIFF
|
||||
diff = Redmine::UnifiedDiff.new(raw, :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 3, diff.first.size
|
||||
|
@ -260,15 +301,15 @@ DIFF
|
|||
end
|
||||
|
||||
def test_offset_range_ascii_2
|
||||
raw = <<-DIFF
|
||||
--- a.txt 2013-04-05 14:19:39.000000000 +0900
|
||||
+++ b.txt 2013-04-05 14:19:51.000000000 +0900
|
||||
@@ -1,3 +1,3 @@
|
||||
aaaa
|
||||
-abc
|
||||
+zabc
|
||||
bbbb
|
||||
DIFF
|
||||
raw = <<~DIFF
|
||||
--- a.txt 2013-04-05 14:19:39.000000000 +0900
|
||||
+++ b.txt 2013-04-05 14:19:51.000000000 +0900
|
||||
@@ -1,3 +1,3 @@
|
||||
aaaa
|
||||
-abc
|
||||
+zabc
|
||||
bbbb
|
||||
DIFF
|
||||
diff = Redmine::UnifiedDiff.new(raw, :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 3, diff.first.size
|
||||
|
@ -277,70 +318,60 @@ DIFF
|
|||
end
|
||||
|
||||
def test_offset_range_japanese_1
|
||||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span></span>".force_encoding('UTF-8')
|
||||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x9e</span>".force_encoding('UTF-8')
|
||||
with_settings :repositories_encodings => '' do
|
||||
diff = Redmine::UnifiedDiff.new(
|
||||
read_diff_fixture('issue-13644-1.diff'), :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 3, diff.first.size
|
||||
assert_equal ja1, diff.first[1].html_line_left
|
||||
assert_equal ja2, diff.first[1].html_line_right
|
||||
assert_equal '日本<span></span>', diff.first[1].html_line_left
|
||||
assert_equal '日本<span>語</span>', diff.first[1].html_line_right
|
||||
end
|
||||
end
|
||||
|
||||
def test_offset_range_japanese_2
|
||||
ja1 = "<span></span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8')
|
||||
ja2 = "<span>\xe3\x81\xab\xe3\x81\xa3\xe3\x81\xbd\xe3\x82\x93</span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8')
|
||||
with_settings :repositories_encodings => '' do
|
||||
diff = Redmine::UnifiedDiff.new(
|
||||
read_diff_fixture('issue-13644-2.diff'), :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 3, diff.first.size
|
||||
assert_equal ja1, diff.first[1].html_line_left
|
||||
assert_equal ja2, diff.first[1].html_line_right
|
||||
assert_equal '<span></span>日本', diff.first[1].html_line_left
|
||||
assert_equal '<span>にっぽん</span>日本', diff.first[1].html_line_right
|
||||
end
|
||||
end
|
||||
|
||||
def test_offset_range_japanese_3
|
||||
# UTF-8 The 1st byte differs.
|
||||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>".force_encoding('UTF-8')
|
||||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe5\xa8\x98</span>".force_encoding('UTF-8')
|
||||
with_settings :repositories_encodings => '' do
|
||||
diff = Redmine::UnifiedDiff.new(
|
||||
read_diff_fixture('issue-13644-3.diff'), :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 3, diff.first.size
|
||||
assert_equal ja1, diff.first[1].html_line_left
|
||||
assert_equal ja2, diff.first[1].html_line_right
|
||||
assert_equal '日本<span>記</span>', diff.first[1].html_line_left
|
||||
assert_equal '日本<span>娘</span>', diff.first[1].html_line_right
|
||||
end
|
||||
end
|
||||
|
||||
def test_offset_range_japanese_4
|
||||
# UTF-8 The 2nd byte differs.
|
||||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>".force_encoding('UTF-8')
|
||||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>".force_encoding('UTF-8')
|
||||
# UTF-8 The 2nd byte differs.
|
||||
with_settings :repositories_encodings => '' do
|
||||
diff = Redmine::UnifiedDiff.new(
|
||||
read_diff_fixture('issue-13644-4.diff'), :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 3, diff.first.size
|
||||
assert_equal ja1, diff.first[1].html_line_left
|
||||
assert_equal ja2, diff.first[1].html_line_right
|
||||
assert_equal '日本<span>記</span>', diff.first[1].html_line_left
|
||||
assert_equal '日本<span>誘</span>', diff.first[1].html_line_right
|
||||
end
|
||||
end
|
||||
|
||||
def test_offset_range_japanese_5
|
||||
# UTF-8 The 2nd byte differs.
|
||||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>ok".force_encoding('UTF-8')
|
||||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>ok".force_encoding('UTF-8')
|
||||
# UTF-8 The 2nd byte differs.
|
||||
with_settings :repositories_encodings => '' do
|
||||
diff = Redmine::UnifiedDiff.new(
|
||||
read_diff_fixture('issue-13644-5.diff'), :type => 'sbs')
|
||||
assert_equal 1, diff.size
|
||||
assert_equal 3, diff.first.size
|
||||
assert_equal ja1, diff.first[1].html_line_left
|
||||
assert_equal ja2, diff.first[1].html_line_right
|
||||
assert_equal '日本<span>記</span>ok', diff.first[1].html_line_left
|
||||
assert_equal '日本<span>誘</span>ok', diff.first[1].html_line_right
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue