diff options
author | Tony Tsang <tony@tcnhk.com> | 2015-02-06 17:02:32 +0800 |
---|---|---|
committer | Tony Tsang <tony@tcnhk.com> | 2015-02-06 17:02:32 +0800 |
commit | fc6d80d619d960b340bf1ebc7131add86985e725 (patch) | |
tree | c0456feb0ea004cc83dad3844fc927f4c3f4bcb6 /models/git_diff.go | |
parent | 16018e832394772591688a261646d3a80787ac9d (diff) | |
download | gitea-fc6d80d619d960b340bf1ebc7131add86985e725.tar.gz gitea-fc6d80d619d960b340bf1ebc7131add86985e725.zip |
Link to previous commited source file (diff.view_file button) instead of returning 404 for deleted files.
Diffstat (limited to 'models/git_diff.go')
-rw-r--r-- | models/git_diff.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/git_diff.go b/models/git_diff.go index 7e91626f1d..9d34ed6271 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -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 |