Skip to content

Commit 6388f66

Browse files
committed
Revert bug fixes in this pull request so that they could be fixed in other PRs
1 parent 35518d0 commit 6388f66

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

services/gitdiff/gitdiff.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,6 @@ parsingLoop:
641641
}
642642
case strings.HasPrefix(line, "new file"):
643643
curFile.Type = DiffFileAdd
644-
curFile.OldName = ""
645644
curFile.IsCreated = true
646645
if strings.HasPrefix(line, "new file mode ") {
647646
curFile.Mode = prepareValue(line, "new file mode ")
@@ -689,7 +688,7 @@ parsingLoop:
689688
if line[len(line)-2] == '\t' {
690689
curFile.Name = curFile.Name[:len(curFile.Name)-1]
691690
}
692-
if curFile.OldName == "" && curFile.Type != DiffFileAdd {
691+
if curFile.OldName == "" {
693692
curFile.OldName = curFile.Name
694693
}
695694
} else {

services/gitdiff/gitdiff_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ func TestParsePatch_singlefile(t *testing.T) {
216216
wantErr bool
217217
addition int
218218
deletion int
219-
Type DiffFileType
220219
oldFilename string
221220
filename string
222221
}
@@ -238,7 +237,6 @@ func TestParsePatch_singlefile(t *testing.T) {
238237
`,
239238
addition: 4,
240239
deletion: 1,
241-
Type: DiffFileChange,
242240
filename: "README.md",
243241
oldFilename: "README.md",
244242
},
@@ -257,7 +255,6 @@ func TestParsePatch_singlefile(t *testing.T) {
257255
+ cut off`,
258256
addition: 4,
259257
deletion: 1,
260-
Type: DiffFileChange,
261258
filename: "A \\ B",
262259
oldFilename: "A \\ B",
263260
},
@@ -274,7 +271,6 @@ index d2186f1..f5c8ed2 100644
274271
\ No newline at end of file`,
275272
addition: 0,
276273
deletion: 1,
277-
Type: DiffFileChange,
278274
filename: "a b/file b/a a/file",
279275
oldFilename: "a b/file b/a a/file",
280276
},
@@ -294,7 +290,6 @@ index 898651a..0000000
294290
`,
295291
addition: 0,
296292
deletion: 5,
297-
Type: DiffFileDel,
298293
filename: "file with blanks",
299294
oldFilename: "file with blanks",
300295
},
@@ -307,7 +302,6 @@ rename to "a\342\200\224as"
307302
`,
308303
addition: 0,
309304
deletion: 0,
310-
Type: DiffFileRename,
311305
oldFilename: "𣐵b†vs",
312306
filename: "a—as",
313307
},
@@ -318,7 +312,6 @@ similarity index 100%
318312
rename from a b/file b/a a/file
319313
rename to a b/a a/file b/b file
320314
`,
321-
Type: DiffFileRename,
322315
oldFilename: "a b/file b/a a/file",
323316
filename: "a b/a a/file b/b file",
324317
},
@@ -332,7 +325,6 @@ index 92e798b..0000000
332325
@@ -1 +0,0 @@
333326
-b b/b
334327
`,
335-
Type: DiffFileDel,
336328
oldFilename: "b b/b",
337329
filename: "b b/b",
338330
addition: 0,
@@ -348,7 +340,6 @@ index 0000000..92e798b
348340
@@ -0,0 +1 @@
349341
+b b/b
350342
`,
351-
Type: DiffFileAdd,
352343
oldFilename: "",
353344
filename: "b b/b",
354345
addition: 1,
@@ -361,7 +352,6 @@ similarity index 100%
361352
rename from b b/b b/b b/b b/b
362353
rename to b
363354
`,
364-
Type: DiffFileRename,
365355
oldFilename: "b b/b b/b b/b b/b",
366356
filename: "b",
367357
},
@@ -372,7 +362,6 @@ similarity index 100%
372362
rename from b b/b b/b b/b b/b
373363
rename to b
374364
`,
375-
Type: DiffFileRename,
376365
oldFilename: "b b/b b/b b/b b/b",
377366
filename: "b",
378367
},
@@ -383,7 +372,6 @@ similarity index 100%
383372
rename from b b/b b/b b/b
384373
rename to b b/b
385374
`,
386-
Type: DiffFileRename,
387375
oldFilename: "b b/b b/b b/b",
388376
filename: "b b/b",
389377
},
@@ -403,7 +391,6 @@ index 6961180..9ba1a00 100644
403391
+++ 3rd line
404392
+-- 4th line
405393
`,
406-
Type: DiffFileChange,
407394
oldFilename: "minuses-and-pluses",
408395
filename: "minuses-and-pluses",
409396
addition: 4,
@@ -431,9 +418,6 @@ index 6961180..9ba1a00 100644
431418
t.Errorf("ParsePath(%q) did not have correct totalDeletion %d, wanted %d", testcase.name, got.TotalDeletion, testcase.deletion)
432419
}
433420
file := got.Files[0]
434-
if file.Type != testcase.Type {
435-
t.Errorf("ParsePath(%q) did not have correct Type %d, wanted %d", testcase.name, file.Type, testcase.Type)
436-
}
437421
if file.Addition != testcase.addition {
438422
t.Errorf("ParsePath(%q) does not have correct file addition %d, wanted %d", testcase.name, file.Addition, testcase.addition)
439423
}

tests/integration/api_pull_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func TestAPIViewPulls(t *testing.T) {
6161
assert.NoError(t, err)
6262
if assert.Len(t, patch.Files, pull.ChangedFiles) {
6363
assert.Equal(t, "File-WoW", patch.Files[0].Name)
64-
assert.Empty(t, patch.Files[0].OldName)
64+
// FIXME: The old name should be empty if it's a file add type
65+
assert.Equal(t, "File-WoW", patch.Files[0].OldName)
6566
assert.EqualValues(t, pull.Additions, patch.Files[0].Addition)
6667
assert.EqualValues(t, pull.Deletions, patch.Files[0].Deletion)
6768
assert.Equal(t, gitdiff.DiffFileAdd, patch.Files[0].Type)
@@ -97,7 +98,7 @@ func TestAPIViewPulls(t *testing.T) {
9798
assert.NoError(t, err)
9899
if assert.Len(t, patch.Files, pull.ChangedFiles) {
99100
assert.Equal(t, "README.md", patch.Files[0].Name)
100-
assert.NotEmpty(t, patch.Files[0].OldName)
101+
assert.Equal(t, "README.md", patch.Files[0].OldName)
101102
assert.EqualValues(t, pull.Additions, patch.Files[0].Addition)
102103
assert.EqualValues(t, pull.Deletions, patch.Files[0].Deletion)
103104
assert.Equal(t, gitdiff.DiffFileChange, patch.Files[0].Type)
@@ -107,7 +108,8 @@ func TestAPIViewPulls(t *testing.T) {
107108
doAPIGetPullFiles(ctx, pull, func(t *testing.T, files []*api.ChangedFile) {
108109
if assert.Len(t, files, pull.ChangedFiles) {
109110
assert.Equal(t, "README.md", files[0].Filename)
110-
assert.Empty(t, files[0].PreviousFilename)
111+
// FIXME: The PreviousFilename name should be the same as Filename if it's a file change
112+
assert.Equal(t, "", files[0].PreviousFilename)
111113
assert.EqualValues(t, pull.Additions, files[0].Additions)
112114
assert.EqualValues(t, pull.Deletions, files[0].Deletions)
113115
assert.Equal(t, "changed", files[0].Status)

0 commit comments

Comments
 (0)