summaryrefslogtreecommitdiffstats
path: root/modules/convert/git_commit.go
diff options
context:
space:
mode:
authorJohn Olheiser <john.olheiser@gmail.com>2022-03-29 10:47:44 -0500
committerGitHub <noreply@github.com>2022-03-29 10:47:44 -0500
commit66f2210feca0b50d305a46a203c2b3d2f4d3790b (patch)
tree43b3630b5fbf0e2dfd1eac5ce0156b82be2016bb /modules/convert/git_commit.go
parent74731c3a5aea71c81e4ca75bde96154f3adf3cfa (diff)
downloadgitea-66f2210feca0b50d305a46a203c2b3d2f4d3790b.tar.gz
gitea-66f2210feca0b50d305a46a203c2b3d2f4d3790b.zip
More commit info from API (#19252)
Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/convert/git_commit.go')
-rw-r--r--modules/convert/git_commit.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/convert/git_commit.go b/modules/convert/git_commit.go
index a5c3112f13..dfd6cb080c 100644
--- a/modules/convert/git_commit.go
+++ b/modules/convert/git_commit.go
@@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/modules/log"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
+ "code.gitea.io/gitea/services/gitdiff"
)
// ToCommitUser convert a git.Signature to an api.CommitUser
@@ -146,6 +147,13 @@ func ToCommit(repo *repo_model.Repository, gitRepo *git.Repository, commit *git.
}
}
+ diff, err := gitdiff.GetDiff(gitRepo, &gitdiff.DiffOptions{
+ AfterCommitID: commit.ID.String(),
+ })
+ if err != nil {
+ return nil, err
+ }
+
return &api.Commit{
CommitMeta: &api.CommitMeta{
URL: repo.APIURL() + "/git/commits/" + url.PathEscape(commit.ID.String()),
@@ -175,10 +183,16 @@ func ToCommit(repo *repo_model.Repository, gitRepo *git.Repository, commit *git.
SHA: commit.ID.String(),
Created: commit.Committer.When,
},
+ Verification: ToVerification(commit),
},
Author: apiAuthor,
Committer: apiCommitter,
Parents: apiParents,
Files: affectedFileList,
+ Stats: &api.CommitStats{
+ Total: diff.TotalAddition + diff.TotalDeletion,
+ Additions: diff.TotalAddition,
+ Deletions: diff.TotalDeletion,
+ },
}, nil
}