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
9090 tests := []testcase{
9191 {
9292 name: "readme.md2readme.md",
93− gitdiff: `diff --git "a/README.md" "b/README.md"
94−--- a/README.md
95−+++ b/README.md
93+ gitdiff: `diff --git "\\a/README.md" "\\b/README.md"
94+--- "\\a/README.md"
95++++ "\\b/README.md"
9696 @@ -1,3 +1,6 @@
9797 # gitea-github-migrator
9898 +
@@ -102,9 +102,10 @@ func TestParsePatch_singlefile(t *testing.T) { · 3 unmodified lines
102102 + cut off
103103 + cut off
104104 `,
105− addition: 4,
106− deletion: 1,
107− filename: "README.md",
105+ addition: 4,
106+ deletion: 1,
107+ filename: "README.md",
108+ oldFilename: "README.md",
108109 },
109110 {
110111 name: "A \\ B",
@@ -119,16 +120,17 @@ func TestParsePatch_singlefile(t *testing.T) { · 8 unmodified lines
119120 Docker Pulls
120121 + cut off
121122 + cut off`,
122− addition: 4,
123− deletion: 1,
124− filename: "A \\ B",
123+ addition: 4,
124+ deletion: 1,
125+ filename: "A \\ B",
126+ oldFilename: "A \\ B",
125127 },
126128 {
127129 name: "really weird filename",
128− gitdiff: `diff --git a/a b/file b/a a/file b/a b/file b/a a/file
130+ gitdiff: `diff --git "\\a/a b/file b/a a/file" "\\b/a b/file b/a a/file"
129131 index d2186f1..f5c8ed2 100644
130−--- a/a b/file b/a a/file
131−+++ b/a b/file b/a a/file
132+--- "\\a/a b/file b/a a/file"
133++++ "\\b/a b/file b/a a/file"
132134 @@ -1,3 +1,2 @@
133135 Create a weird file.
134136
@@ -141,10 +143,10 @@ index d2186f1..f5c8ed2 100644 · 6 unmodified lines
141143 },
142144 {
143145 name: "delete file with blanks",
144− gitdiff: `diff --git a/file with blanks b/file with blanks
146+ gitdiff: `diff --git "\\a/file with blanks" "\\b/file with blanks"
145147 deleted file mode 100644
146148 index 898651a..0000000
147−--- a/file with blanks
149+--- "\\a/file with blanks"
148150 +++ /dev/null
149151 @@ -1,5 +0,0 @@
150152 -a blank file
@@ -153,9 +155,10 @@ index 898651a..0000000 · 2 unmodified lines
153155 -
154156 -the 5th line is the last
155157 `,
156− addition: 0,
157− deletion: 5,
158− filename: "file with blanks",
158+ addition: 0,
159+ deletion: 5,
160+ filename: "file with blanks",
161+ oldFilename: "file with blanks",
159162 },
160163 {
161164 name: "rename a—as",
@@ -171,7 +174,7 @@ rename to "a\342\200\224as" · 9 unmodified lines
171174 },
172175 {
173176 name: "rename with spaces",
174− gitdiff: `diff --git a/a b/file b/a a/file b/a b/a a/file b/b file
177+ gitdiff: `diff --git "\\a/a b/file b/a a/file" "\\b/a b/a a/file b/b file"
175178 similarity index 100%
176179 rename from a b/file b/a a/file
177180 rename to a b/a a/file b/b file