Skip to content

Commit

Permalink
Fix diff of renamed and modified file
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig committed Jun 14, 2017
1 parent 274149d commit 8e94b51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions models/git_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,12 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
}

curFile = &DiffFile{
Name: a,
Index: len(diff.Files) + 1,
Type: DiffFileChange,
Sections: make([]*DiffSection, 0, 10),
Name: b,
OldName: a,
Index: len(diff.Files) + 1,
Type: DiffFileChange,
Sections: make([]*DiffSection, 0, 10),
IsRenamed: a != b,
}
diff.Files = append(diff.Files, curFile)
if len(diff.Files) >= maxFiles {
Expand Down Expand Up @@ -401,9 +403,6 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
curFile.Type = DiffFileChange
case strings.HasPrefix(line, "similarity index 100%"):
curFile.Type = DiffFileRename
curFile.IsRenamed = true
curFile.OldName = curFile.Name
curFile.Name = b
}
if curFile.Type > 0 {
if strings.HasSuffix(line, " 160000\n") {
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/diff/box.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
{{end}}
</h4>
<div class="ui attached table segment">
{{if not $file.IsRenamed}}
{{if ne $file.Type 4}}
{{$isImage := (call $.IsImageFile $file.Name)}}
{{if and $isImage}}
<div class="center">
Expand Down

0 comments on commit 8e94b51

Please sign in to comment.