Browse Source

Fix diff of renamed and modified file (#1967)

for-closed-social
Ethan Koenig 7 years ago
committed by Bo-Yi Wu
parent
commit
57cabb3ad3
2 changed files with 7 additions and 8 deletions
  1. +6
    -7
      models/git_diff.go
  2. +1
    -1
      templates/repo/diff/box.tmpl

+ 6
- 7
models/git_diff.go View File

@ -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 {
@ -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") {

+ 1
- 1
templates/repo/diff/box.tmpl View File

@ -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">

Loading…
Cancel
Save