forked from forgejo/forgejo
Link to previous commited source file (diff.view_file button) instead of returning 404 for deleted files.
This commit is contained in:
parent
16018e8323
commit
fc6d80d619
3 changed files with 16 additions and 0 deletions
|
@ -60,6 +60,8 @@ type DiffFile struct {
|
|||
Index int
|
||||
Addition, Deletion int
|
||||
Type int
|
||||
IsCreated bool
|
||||
IsDeleted bool
|
||||
IsBin bool
|
||||
Sections []*DiffSection
|
||||
}
|
||||
|
@ -181,10 +183,16 @@ func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff
|
|||
switch {
|
||||
case strings.HasPrefix(scanner.Text(), "new file"):
|
||||
curFile.Type = DIFF_FILE_ADD
|
||||
curFile.IsDeleted = false
|
||||
curFile.IsCreated = true
|
||||
case strings.HasPrefix(scanner.Text(), "deleted"):
|
||||
curFile.Type = DIFF_FILE_DEL
|
||||
curFile.IsCreated = false
|
||||
curFile.IsDeleted = true
|
||||
case strings.HasPrefix(scanner.Text(), "index"):
|
||||
curFile.Type = DIFF_FILE_CHANGE
|
||||
curFile.IsCreated = false
|
||||
curFile.IsDeleted = false
|
||||
}
|
||||
if curFile.Type > 0 {
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue