Add commit stats and verification (#584)

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/584
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-committed-by: John Olheiser <john.olheiser@gmail.com>
This commit is contained in:
John Olheiser 2022-04-28 18:58:54 +08:00 committed by 6543
parent 89a4b0be6e
commit ce9d46682d
2 changed files with 16 additions and 5 deletions

View file

@ -32,11 +32,19 @@ type CommitUser struct {
// RepoCommit contains information of a commit in the context of a repository. // RepoCommit contains information of a commit in the context of a repository.
type RepoCommit struct { type RepoCommit struct {
URL string `json:"url"` URL string `json:"url"`
Author *CommitUser `json:"author"` Author *CommitUser `json:"author"`
Committer *CommitUser `json:"committer"` Committer *CommitUser `json:"committer"`
Message string `json:"message"` Message string `json:"message"`
Tree *CommitMeta `json:"tree"` 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. // Commit contains information generated from a Git commit.
@ -48,6 +56,7 @@ type Commit struct {
Committer *User `json:"committer"` Committer *User `json:"committer"`
Parents []*CommitMeta `json:"parents"` Parents []*CommitMeta `json:"parents"`
Files []*CommitAffectedFiles `json:"files"` Files []*CommitAffectedFiles `json:"files"`
Stats *CommitStats `json:"stats"`
} }
// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE // CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE

View file

@ -22,4 +22,6 @@ func TestListRepoCommits(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, l, 1) assert.Len(t, l, 1)
assert.EqualValues(t, "Initial commit\n", l[0].RepoCommit.Message) 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)
} }