History

Finally fix diff names (#13136)

* Finally fix diff names #12771 attempted to fix diff by avoiding the git diff line as it is possible to have an ambiguous line here. #12254 attempted to fix diff by assuming that names would quoted if they needed to be and if one was quoted then both would be. Both of these were wrong. I have now discovered `--src-prefix` and `--dst-prefix` which means that we can set this in such a way to force the git diff to always be unambiguous. Therefore this PR rollsback most of the changes in #12771 and uses these options to fix this. Signed-off-by: Andrew Thornton <art27@cantab.net> * Update services/gitdiff/gitdiff.go * Update services/gitdiff/gitdiff.go * Update modules/repofiles/temp_repo.go * fix test Signed-off-by: Andrew Thornton <art27@cantab.net>

zeripath committed 6 years ago

Commit edfebe61 parent aa73b7b3 files · +81 −124Browse files

Showing the changes to services/gitdiff/gitdiff_test.go (1 of 3 files). Show all

Unified · Split

services/gitdiff/gitdiff_test.go+21−18
@@ -90,9 +90,9 @@ func TestParsePatch_singlefile(t *testing.T) { · 89 unmodified lines
90 tests := []testcase{90 tests := []testcase{
91 {91 {
92 name: "readme.md2readme.md",92 name: "readme.md2readme.md",
93 gitdiff: `diff --git "a/README.md" "b/README.md"93 gitdiff: `diff --git "\\a/README.md" "\\b/README.md"
94--- a/README.md94--- "\\a/README.md"
95+++ b/README.md95+++ "\\b/README.md"
96@@ -1,3 +1,6 @@96@@ -1,3 +1,6 @@
97 # gitea-github-migrator97 # gitea-github-migrator
98+98+
@@ -102,9 +102,10 @@ func TestParsePatch_singlefile(t *testing.T) { · 3 unmodified lines
102+ cut off102+ cut off
103+ cut off103+ cut off
104`,104`,
105 addition: 4,105 addition: 4,
106 deletion: 1,106 deletion: 1,
107 filename: "README.md",107 filename: "README.md",
108 oldFilename: "README.md",
108 },109 },
109 {110 {
110 name: "A \\ B",111 name: "A \\ B",
@@ -119,16 +120,17 @@ func TestParsePatch_singlefile(t *testing.T) { · 8 unmodified lines
119 Docker Pulls120 Docker Pulls
120+ cut off121+ cut off
121+ cut off`,122+ cut off`,
122 addition: 4,123 addition: 4,
123 deletion: 1,124 deletion: 1,
124 filename: "A \\ B",125 filename: "A \\ B",
126 oldFilename: "A \\ B",
125 },127 },
126 {128 {
127 name: "really weird filename",129 name: "really weird filename",
128 gitdiff: `diff --git a/a b/file b/a a/file b/a b/file b/a a/file130 gitdiff: `diff --git "\\a/a b/file b/a a/file" "\\b/a b/file b/a a/file"
129index d2186f1..f5c8ed2 100644131index d2186f1..f5c8ed2 100644
130--- a/a b/file b/a a/file 132--- "\\a/a b/file b/a a/file"
131+++ b/a b/file b/a a/file 133+++ "\\b/a b/file b/a a/file"
132@@ -1,3 +1,2 @@134@@ -1,3 +1,2 @@
133 Create a weird file.135 Create a weird file.
134 136
@@ -141,10 +143,10 @@ index d2186f1..f5c8ed2 100644 · 6 unmodified lines
141 },143 },
142 {144 {
143 name: "delete file with blanks",145 name: "delete file with blanks",
144 gitdiff: `diff --git a/file with blanks b/file with blanks146 gitdiff: `diff --git "\\a/file with blanks" "\\b/file with blanks"
145deleted file mode 100644147deleted file mode 100644
146index 898651a..0000000148index 898651a..0000000
147--- a/file with blanks 149--- "\\a/file with blanks"
148+++ /dev/null150+++ /dev/null
149@@ -1,5 +0,0 @@151@@ -1,5 +0,0 @@
150-a blank file152-a blank file
@@ -153,9 +155,10 @@ index 898651a..0000000 · 2 unmodified lines
153-155-
154-the 5th line is the last156-the 5th line is the last
155`,157`,
156 addition: 0,158 addition: 0,
157 deletion: 5,159 deletion: 5,
158 filename: "file with blanks",160 filename: "file with blanks",
161 oldFilename: "file with blanks",
159 },162 },
160 {163 {
161 name: "rename a—as",164 name: "rename a—as",
@@ -171,7 +174,7 @@ rename to "a\342\200\224as" · 9 unmodified lines
171 },174 },
172 {175 {
173 name: "rename with spaces",176 name: "rename with spaces",
174 gitdiff: `diff --git a/a b/file b/a a/file b/a b/a a/file b/b file177 gitdiff: `diff --git "\\a/a b/file b/a a/file" "\\b/a b/a a/file b/b file"
175similarity index 100%178similarity index 100%
176rename from a b/file b/a a/file179rename from a b/file b/a a/file
177rename to a b/a a/file b/b file180rename to a b/a a/file b/b file