forked from NYANDEV/forgejo
Backport #13136 it is possible to have an ambiguous line here. 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>
This commit is contained in:
parent
09abdb8a65
commit
99fb256411
3 changed files with 81 additions and 124 deletions
|
@ -56,9 +56,9 @@ func TestParsePatch_singlefile(t *testing.T) {
|
|||
tests := []testcase{
|
||||
{
|
||||
name: "readme.md2readme.md",
|
||||
gitdiff: `diff --git "a/README.md" "b/README.md"
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
gitdiff: `diff --git "\\a/README.md" "\\b/README.md"
|
||||
--- "\\a/README.md"
|
||||
+++ "\\b/README.md"
|
||||
@@ -1,3 +1,6 @@
|
||||
# gitea-github-migrator
|
||||
+
|
||||
|
@ -68,9 +68,10 @@ func TestParsePatch_singlefile(t *testing.T) {
|
|||
+ cut off
|
||||
+ cut off
|
||||
`,
|
||||
addition: 4,
|
||||
deletion: 1,
|
||||
filename: "README.md",
|
||||
addition: 4,
|
||||
deletion: 1,
|
||||
filename: "README.md",
|
||||
oldFilename: "README.md",
|
||||
},
|
||||
{
|
||||
name: "A \\ B",
|
||||
|
@ -85,16 +86,17 @@ func TestParsePatch_singlefile(t *testing.T) {
|
|||
Docker Pulls
|
||||
+ cut off
|
||||
+ cut off`,
|
||||
addition: 4,
|
||||
deletion: 1,
|
||||
filename: "A \\ B",
|
||||
addition: 4,
|
||||
deletion: 1,
|
||||
filename: "A \\ B",
|
||||
oldFilename: "A \\ B",
|
||||
},
|
||||
{
|
||||
name: "really weird filename",
|
||||
gitdiff: `diff --git a/a b/file b/a a/file b/a b/file b/a a/file
|
||||
gitdiff: `diff --git "\\a/a b/file b/a a/file" "\\b/a b/file b/a a/file"
|
||||
index d2186f1..f5c8ed2 100644
|
||||
--- a/a b/file b/a a/file
|
||||
+++ b/a b/file b/a a/file
|
||||
--- "\\a/a b/file b/a a/file"
|
||||
+++ "\\b/a b/file b/a a/file"
|
||||
@@ -1,3 +1,2 @@
|
||||
Create a weird file.
|
||||
|
||||
|
@ -107,10 +109,10 @@ index d2186f1..f5c8ed2 100644
|
|||
},
|
||||
{
|
||||
name: "delete file with blanks",
|
||||
gitdiff: `diff --git a/file with blanks b/file with blanks
|
||||
gitdiff: `diff --git "\\a/file with blanks" "\\b/file with blanks"
|
||||
deleted file mode 100644
|
||||
index 898651a..0000000
|
||||
--- a/file with blanks
|
||||
--- "\\a/file with blanks"
|
||||
+++ /dev/null
|
||||
@@ -1,5 +0,0 @@
|
||||
-a blank file
|
||||
|
@ -119,9 +121,10 @@ index 898651a..0000000
|
|||
-
|
||||
-the 5th line is the last
|
||||
`,
|
||||
addition: 0,
|
||||
deletion: 5,
|
||||
filename: "file with blanks",
|
||||
addition: 0,
|
||||
deletion: 5,
|
||||
filename: "file with blanks",
|
||||
oldFilename: "file with blanks",
|
||||
},
|
||||
{
|
||||
name: "rename a—as",
|
||||
|
@ -137,7 +140,7 @@ rename to "a\342\200\224as"
|
|||
},
|
||||
{
|
||||
name: "rename with spaces",
|
||||
gitdiff: `diff --git a/a b/file b/a a/file b/a b/a a/file b/b file
|
||||
gitdiff: `diff --git "\\a/a b/file b/a a/file" "\\b/a b/a a/file b/b file"
|
||||
similarity index 100%
|
||||
rename from a b/file b/a a/file
|
||||
rename to a b/a a/file b/b file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue