@@ -10,36 +10,47 @@ import "fmt"
1010// ContributorStats represents a contributor to a repository and their
1111// weekly contributions to a given repo.
1212type ContributorStats struct {
13- Author * Contributor `json:"author,omitempty"`
14- Total * int `json:"total,omitempty"`
15- Weeks []WeeklyHash `json:"weeks,omitempty"`
13+ Author * Contributor `json:"author,omitempty"`
14+ Total * int `json:"total,omitempty"`
15+ Weeks []WeeklyStats `json:"weeks,omitempty"`
1616}
1717
18- // WeeklyHash represents the number of additions, deletions and commits
18+ func (c ContributorStats ) String () string {
19+ return Stringify (c )
20+ }
21+
22+ // WeeklyStats represents the number of additions, deletions and commits
1923// a Contributor made in a given week.
20- type WeeklyHash struct {
21- Week * int `json:"w,omitempty"`
22- Additions * int `json:"a,omitempty"`
23- Deletions * int `json:"d,omitempty"`
24- Commits * int `json:"c,omitempty"`
24+ type WeeklyStats struct {
25+ Week * Timestamp `json:"w,omitempty"`
26+ Additions * int `json:"a,omitempty"`
27+ Deletions * int `json:"d,omitempty"`
28+ Commits * int `json:"c,omitempty"`
29+ }
30+
31+ func (w WeeklyStats ) String () string {
32+ return Stringify (w )
2533}
2634
27- // ListContributorsStats gets a repo's contributor list with additions, deletions and commit counts.
28- // If this is the first time these statistics are requested for the given repository, this method
29- // will return a non-nil error and a status code of 202. This is because this is the status that github
30- // returns to signify that it is now computing the requested statistics. A follow up request, after
31- // a delay of a second or so, should result in a successful request.
35+ // ListContributorsStats gets a repo's contributor list with additions,
36+ // deletions and commit counts.
37+ //
38+ // If this is the first time these statistics are requested for the given
39+ // repository, this method will return a non-nil error and a status code of
40+ // 202. This is because this is the status that github returns to signify that
41+ // it is now computing the requested statistics. A follow up request, after a
42+ // delay of a second or so, should result in a successful request.
3243//
3344// GitHub API docs: https://developer.github.com/v3/repos/statistics/#contributors
34- func (s * RepositoriesService ) ListContributorsStats (owner , repo string ) (* []ContributorStats , * Response , error ) {
45+ func (s * RepositoriesService ) ListContributorsStats (owner , repo string ) ([]ContributorStats , * Response , error ) {
3546 u := fmt .Sprintf ("repos/%v/%v/stats/contributors" , owner , repo )
3647 req , err := s .client .NewRequest ("GET" , u , nil )
3748 if err != nil {
3849 return nil , nil , err
3950 }
4051
41- contributorStats := new ( []ContributorStats )
42- resp , err := s .client .Do (req , contributorStats )
52+ var contributorStats []ContributorStats
53+ resp , err := s .client .Do (req , & contributorStats )
4354 if err != nil {
4455 return nil , resp , err
4556 }
@@ -50,30 +61,35 @@ func (s *RepositoriesService) ListContributorsStats(owner, repo string) (*[]Cont
5061// WeeklyCommitActivity represents the weekly commit activity for a repository.
5162// The days array is a group of commits per day, starting on Sunday.
5263type WeeklyCommitActivity struct {
53- Days []int `json:"days,omitempty"`
54- Total * int `json:"total,omitempty"`
55- Week * int `json:"week,omitempty"`
64+ Days []int `json:"days,omitempty"`
65+ Total * int `json:"total,omitempty"`
66+ Week * Timestamp `json:"week,omitempty"`
67+ }
68+
69+ func (w WeeklyCommitActivity ) String () string {
70+ return Stringify (w )
5671}
5772
5873// ListCommitActivity returns the last year of commit activity
5974// grouped by week. The days array is a group of commits per day,
60- // starting on Sunday. If this is the first time these statistics are
61- // requested for the given repository, this method will return a
62- // non-nil error and a status code of 202. This is because this is the
63- // status that github returns to signify that it is now computing the
64- // requested statistics. A follow up request, after a delay of a second
65- // or so, should result in a successful request.
75+ // starting on Sunday.
76+ //
77+ // If this is the first time these statistics are requested for the given
78+ // repository, this method will return a non-nil error and a status code of
79+ // 202. This is because this is the status that github returns to signify that
80+ // it is now computing the requested statistics. A follow up request, after a
81+ // delay of a second or so, should result in a successful request.
6682//
6783// GitHub API docs: https://developer.github.com/v3/repos/statistics/#commit-activity
68- func (s * RepositoriesService ) ListCommitActivity (owner , repo string ) (* []WeeklyCommitActivity , * Response , error ) {
84+ func (s * RepositoriesService ) ListCommitActivity (owner , repo string ) ([]WeeklyCommitActivity , * Response , error ) {
6985 u := fmt .Sprintf ("repos/%v/%v/stats/commit_activity" , owner , repo )
7086 req , err := s .client .NewRequest ("GET" , u , nil )
7187 if err != nil {
7288 return nil , nil , err
7389 }
7490
75- weeklyCommitActivity := new ( []WeeklyCommitActivity )
76- resp , err := s .client .Do (req , weeklyCommitActivity )
91+ var weeklyCommitActivity []WeeklyCommitActivity
92+ resp , err := s .client .Do (req , & weeklyCommitActivity )
7793 if err != nil {
7894 return nil , resp , err
7995 }
@@ -89,6 +105,10 @@ type RepositoryParticipation struct {
89105 Owner []int `json:"owner,omitempty"`
90106}
91107
108+ func (r RepositoryParticipation ) String () string {
109+ return Stringify (r )
110+ }
111+
92112// ListParticipation returns the total commit counts for the 'owner'
93113// and total commit counts in 'all'. 'all' is everyone combined,
94114// including the 'owner' in the last 52 weeks. If you’d like to get
0 commit comments