forked from octokit/go-octokit
/
commits.go
72 lines (65 loc) · 2.35 KB
/
commits.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package octokat
import (
"fmt"
"time"
)
type CommitFile struct {
Additions int `json:"additions,omitempty"`
BlobURL string `json:"blob_url,omitempty"`
Changes int `json:"changes,omitempty"`
ContentsURL string `json:"contents_url,omitempty"`
Deletions int `json:"deletions,omitempty"`
Filename string `json:"filename,omitempty"`
Patch string `json:"patch,omitempty"`
RawURL string `json:"raw_url,omitempty"`
Sha string `json:"sha,omitempty"`
Status string `json:"status,omitempty"`
}
type CommitStats struct {
Additions int `json:"additions,omitempty"`
Deletions int `json:"deletions,omitempty"`
Total int `json:"total,omitempty"`
}
type CommitCommit struct {
Author struct {
Date *time.Time `json:"date,omitempty"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
} `json:"author,omitempty"`
CommentCount int `json:"comment_count,omitempty"`
Committer struct {
Date *time.Time `json:"date,omitempty"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
} `json:"committer,omitempty"`
Message string `json:"message,omitempty"`
Tree struct {
Sha string `json:"sha,omitempty"`
URL string `json:"url,omitempty"`
} `json:"tree,omitempty"`
URL string `json:"url,omitempty"`
}
type Commit struct {
Label string `json:"label,omitempty"`
Ref string `json:"ref,omitempty"`
User User `json:"user,omitempty"`
Repo Repository `json:"repo,omitempty"`
CommentsURL string `json:"comments_url,omitempty"`
Commit *CommitCommit `json:"commit,omitempty"`
Files []CommitFile `json:"files,omitempty"`
HtmlURL string `json:"html_url,omitempty"`
Parents []Commit `json:"parents,omitempty"`
Sha string `json:"sha,omitempty"`
Stats CommitStats `json:"stats,omitempty"`
URL string `json:"url,omitempty"`
}
func (c *Client) Commits(repo Repo, number string, options *Options) (commits []Commit, err error) {
path := fmt.Sprintf("repos/%s/pulls/%s/commits", repo, number)
err = c.jsonGet(path, options, &commits)
return
}
func (c *Client) Commit(repo Repo, ref string, options *Options) (commit Commit, err error) {
path := fmt.Sprintf("repos/%s/commits/%s", repo, ref)
err = c.jsonGet(path, options, &commit)
return
}