From ce9d46682d65d9c2e5b8857890333f3f1f64c9e5 Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Thu, 28 Apr 2022 18:58:54 +0800 Subject: [PATCH] Add commit stats and verification (#584) Co-authored-by: jolheiser Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/584 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: Lunny Xiao Co-authored-by: John Olheiser Co-committed-by: John Olheiser --- gitea/repo_commit.go | 19 ++++++++++++++----- gitea/repo_commit_test.go | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gitea/repo_commit.go b/gitea/repo_commit.go index 9bb65b3..5714173 100644 --- a/gitea/repo_commit.go +++ b/gitea/repo_commit.go @@ -32,11 +32,19 @@ type CommitUser struct { // RepoCommit contains information of a commit in the context of a repository. type RepoCommit struct { - URL string `json:"url"` - Author *CommitUser `json:"author"` - Committer *CommitUser `json:"committer"` - Message string `json:"message"` - Tree *CommitMeta `json:"tree"` + URL string `json:"url"` + Author *CommitUser `json:"author"` + Committer *CommitUser `json:"committer"` + Message string `json:"message"` + Tree *CommitMeta `json:"tree"` + Verification *PayloadCommitVerification `json:"verification"` +} + +// CommitStats contains stats from a Git commit +type CommitStats struct { + Total int `json:"total"` + Additions int `json:"additions"` + Deletions int `json:"deletions"` } // Commit contains information generated from a Git commit. @@ -48,6 +56,7 @@ type Commit struct { Committer *User `json:"committer"` Parents []*CommitMeta `json:"parents"` Files []*CommitAffectedFiles `json:"files"` + Stats *CommitStats `json:"stats"` } // CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE diff --git a/gitea/repo_commit_test.go b/gitea/repo_commit_test.go index 3cfed5b..1219a05 100644 --- a/gitea/repo_commit_test.go +++ b/gitea/repo_commit_test.go @@ -22,4 +22,6 @@ func TestListRepoCommits(t *testing.T) { assert.NoError(t, err) assert.Len(t, l, 1) assert.EqualValues(t, "Initial commit\n", l[0].RepoCommit.Message) + assert.EqualValues(t, "gpg.error.not_signed_commit", l[0].RepoCommit.Verification.Reason) + assert.EqualValues(t, 100, l[0].Stats.Additions) }