Skip to content

Commit 4a9d768

Browse files
committed
avoid abused GetDiff
1 parent 44c2766 commit 4a9d768

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

services/convert/git_commit.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
api "code.gitea.io/gitea/modules/structs"
1616
"code.gitea.io/gitea/modules/util"
1717
ctx "code.gitea.io/gitea/services/context"
18-
"code.gitea.io/gitea/services/gitdiff"
1918
)
2019

2120
// ToCommitUser convert a git.Signature to an api.CommitUser
@@ -210,17 +209,15 @@ func ToCommit(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Rep
210209

211210
// Get diff stats for commit
212211
if opts.Stat {
213-
diff, err := gitdiff.GetDiff(ctx, gitRepo, &gitdiff.DiffOptions{
214-
AfterCommitID: commit.ID.String(),
215-
})
212+
_, totalAddition, totalDeletion, err := git.GetDiffShortStat(gitRepo.Ctx, repo.RepoPath(), nil, commit.ID.String())
216213
if err != nil {
217214
return nil, err
218215
}
219216

220217
res.Stats = &api.CommitStats{
221-
Total: diff.TotalAddition + diff.TotalDeletion,
222-
Additions: diff.TotalAddition,
223-
Deletions: diff.TotalDeletion,
218+
Total: totalAddition + totalDeletion,
219+
Additions: totalAddition,
220+
Deletions: totalDeletion,
224221
}
225222
}
226223

0 commit comments

Comments
 (0)