aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2025-03-08 17:36:08 +0800
committerGitHub <noreply@github.com>2025-03-08 17:36:08 +0800
commit6422f05a4e2610a31b6137267b7bf53ae1b2b093 (patch)
treed5c98e036b7dab5362a40f638e356e10b5dd3861 /services/repository
parent1b2dffff8ed265cb799a2c22202c7818989330e2 (diff)
downloadgitea-6422f05a4e2610a31b6137267b7bf53ae1b2b093.tar.gz
gitea-6422f05a4e2610a31b6137267b7bf53ae1b2b093.zip
Decouple diff stats query from actual diffing (#33810)
The diff stats are no longer part of the diff generation. Use `GetDiffShortStat` instead to get the total number of changed files, added lines, and deleted lines. As such, `gitdiff.GetDiff` can be simplified: It should not do more than expected. And do not run "git diff --shortstat" for pull list. Fix #31492
Diffstat (limited to 'services/repository')
-rw-r--r--services/repository/files/diff_test.go3
-rw-r--r--services/repository/files/temp_repo.go5
2 files changed, 0 insertions, 8 deletions
diff --git a/services/repository/files/diff_test.go b/services/repository/files/diff_test.go
index b7bdcd8ecf..38cb1d675b 100644
--- a/services/repository/files/diff_test.go
+++ b/services/repository/files/diff_test.go
@@ -30,8 +30,6 @@ func TestGetDiffPreview(t *testing.T) {
content := "# repo1\n\nDescription for repo1\nthis is a new line"
expectedDiff := &gitdiff.Diff{
- TotalAddition: 2,
- TotalDeletion: 1,
Files: []*gitdiff.DiffFile{
{
Name: "README.md",
@@ -114,7 +112,6 @@ 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, ctx.Repo.Repository, branch, treePath, content)
diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go
index 4c4a85c5b1..95528a6fd3 100644
--- a/services/repository/files/temp_repo.go
+++ b/services/repository/files/temp_repo.go
@@ -409,11 +409,6 @@ func (t *TemporaryUploadRepository) DiffIndex() (*gitdiff.Diff, error) {
return nil, fmt.Errorf("unable to run diff-index pipeline in temporary repo: %w", err)
}
- diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(t.ctx, t.basePath, git.TrustedCmdArgs{"--cached"}, "HEAD")
- if err != nil {
- return nil, err
- }
-
return diff, nil
}