Skip to content

Commit 6a6f061

Browse files
ethantkoenigappleboy
authored andcommitted
Fix diff of renamed and modified file (#2136)
1 parent 6caf04c commit 6a6f061

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

models/git_diff.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,12 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
366366
}
367367

368368
curFile = &DiffFile{
369-
Name: a,
370-
Index: len(diff.Files) + 1,
371-
Type: DiffFileChange,
372-
Sections: make([]*DiffSection, 0, 10),
369+
Name: b,
370+
OldName: a,
371+
Index: len(diff.Files) + 1,
372+
Type: DiffFileChange,
373+
Sections: make([]*DiffSection, 0, 10),
374+
IsRenamed: a != b,
373375
}
374376
diff.Files = append(diff.Files, curFile)
375377
if len(diff.Files) >= maxFiles {
@@ -402,9 +404,6 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
402404
curFile.Type = DiffFileChange
403405
case strings.HasPrefix(line, "similarity index 100%"):
404406
curFile.Type = DiffFileRename
405-
curFile.IsRenamed = true
406-
curFile.OldName = curFile.Name
407-
curFile.Name = b
408407
}
409408
if curFile.Type > 0 {
410409
if strings.HasSuffix(line, " 160000\n") {

templates/repo/diff/box.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
{{end}}
7979
</h4>
8080
<div class="ui attached table segment">
81-
{{if not $file.IsRenamed}}
81+
{{if ne $file.Type 4}}
8282
{{$isImage := (call $.IsImageFile $file.Name)}}
8383
{{if and $isImage}}
8484
<div class="center">

0 commit comments

Comments
 (0)