aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repofiles
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-05-26 06:58:07 +0100
committerGitHub <noreply@github.com>2020-05-26 01:58:07 -0400
commit5cb201dc93bf41556556f2154ea28755907fd550 (patch)
treeeefbd70bb80a2b2204a18b776f9d0198855e087b /modules/repofiles
parentb97917a6e7b7a7852d1c0f39a96e06eeb7aab6de (diff)
downloadgitea-5cb201dc93bf41556556f2154ea28755907fd550.tar.gz
gitea-5cb201dc93bf41556556f2154ea28755907fd550.zip
Fix numbr of files, total additions, and deletions (#11614)
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules/repofiles')
-rw-r--r--modules/repofiles/diff_test.go1
-rw-r--r--modules/repofiles/temp_repo.go5
2 files changed, 6 insertions, 0 deletions
diff --git a/modules/repofiles/diff_test.go b/modules/repofiles/diff_test.go
index 4e1d5b13eb..5c09e180f3 100644
--- a/modules/repofiles/diff_test.go
+++ b/modules/repofiles/diff_test.go
@@ -108,6 +108,7 @@ func TestGetDiffPreview(t *testing.T) {
},
IsIncomplete: false,
}
+ expectedDiff.NumFiles = len(expectedDiff.Files)
t.Run("with given branch", func(t *testing.T) {
diff, err := GetDiffPreview(ctx.Repo.Repository, branch, treePath, content)
diff --git a/modules/repofiles/temp_repo.go b/modules/repofiles/temp_repo.go
index 89f9b0b208..2b03db8b4a 100644
--- a/modules/repofiles/temp_repo.go
+++ b/modules/repofiles/temp_repo.go
@@ -299,6 +299,11 @@ func (t *TemporaryUploadRepository) DiffIndex() (*gitdiff.Diff, error) {
t.repo.FullName(), err, stderr)
}
+ diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(t.basePath, "--cached", "HEAD")
+ if err != nil {
+ return nil, err
+ }
+
return diff, nil
}