Signed-off-by: Andrew Thornton <art27@cantab.net>
Showing the changes to services/gitdiff/gitdiff.go (1 of 8 files). Show all
Unified · Split
| @@ -367,9 +367,9 @@ func getCommitFileLineCount(commit *git.Commit, filePath string) int { · 366 unmodified lines | ||
| 367 | 367 | |
| 368 | 368 | // Diff represents a difference between two git trees. |
| 369 | 369 | type Diff struct { |
| 370 | − TotalAddition, TotalDeletion int | |
| 371 | − Files []*DiffFile | |
| 372 | − IsIncomplete bool | |
| 370 | + NumFiles, TotalAddition, TotalDeletion int | |
| 371 | + Files []*DiffFile | |
| 372 | + IsIncomplete bool | |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | // LoadComments loads comments into each line |
| @@ -398,11 +398,6 @@ func (diff *Diff) LoadComments(issue *models.Issue, currentUser *models.User) er · 22 unmodified lines | ||
| 398 | 398 | return nil |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | −// NumFiles returns number of files changes in a diff. | |
| 402 | −func (diff *Diff) NumFiles() int { | |
| 403 | − return len(diff.Files) | |
| 404 | −} | |
| 405 | − | |
| 406 | 401 | const cmdDiffHead = "diff --git " |
| 407 | 402 | |
| 408 | 403 | // ParsePatch builds a Diff object from a io.Reader and some |
| @@ -639,7 +634,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D · 230 unmodified lines | ||
| 639 | 634 | } |
| 640 | 635 | } |
| 641 | 636 | } |
| 642 | − | |
| 637 | + diff.NumFiles = len(diff.Files) | |
| 643 | 638 | return diff, nil |
| 644 | 639 | } |
| 645 | 640 | |
| @@ -716,6 +711,11 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID · 70 unmodified lines | ||
| 716 | 711 | return nil, fmt.Errorf("Wait: %v", err) |
| 717 | 712 | } |
| 718 | 713 | |
| 714 | + diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(repoPath, beforeCommitID+"..."+afterCommitID) | |
| 715 | + if err != nil { | |
| 716 | + return nil, err | |
| 717 | + } | |
| 718 | + | |
| 719 | 719 | return diff, nil |
| 720 | 720 | } |
| 721 | 721 | |