Merge v1.2.1-master

Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
Emile Vauge 2017-04-11 17:10:46 +02:00
parent a590155b0b
commit aeb17182b4
No known key found for this signature in database
GPG key ID: D808B4C167352E59
396 changed files with 27271 additions and 9969 deletions

View file

@ -6,6 +6,7 @@
package github
import (
"context"
"fmt"
"time"
)
@ -44,8 +45,8 @@ func (w WeeklyStats) String() string {
// it is now computing the requested statistics. A follow up request, after a
// delay of a second or so, should result in a successful request.
//
// GitHub API Docs: https://developer.github.com/v3/repos/statistics/#contributors
func (s *RepositoriesService) ListContributorsStats(owner, repo string) ([]*ContributorStats, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/statistics/#contributors
func (s *RepositoriesService) ListContributorsStats(ctx context.Context, owner, repo string) ([]*ContributorStats, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/stats/contributors", owner, repo)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@ -53,12 +54,12 @@ func (s *RepositoriesService) ListContributorsStats(owner, repo string) ([]*Cont
}
var contributorStats []*ContributorStats
resp, err := s.client.Do(req, &contributorStats)
resp, err := s.client.Do(ctx, req, &contributorStats)
if err != nil {
return nil, resp, err
}
return contributorStats, resp, err
return contributorStats, resp, nil
}
// WeeklyCommitActivity represents the weekly commit activity for a repository.
@ -83,8 +84,8 @@ func (w WeeklyCommitActivity) String() string {
// it is now computing the requested statistics. A follow up request, after a
// delay of a second or so, should result in a successful request.
//
// GitHub API Docs: https://developer.github.com/v3/repos/statistics/#commit-activity
func (s *RepositoriesService) ListCommitActivity(owner, repo string) ([]*WeeklyCommitActivity, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/statistics/#commit-activity
func (s *RepositoriesService) ListCommitActivity(ctx context.Context, owner, repo string) ([]*WeeklyCommitActivity, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/stats/commit_activity", owner, repo)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@ -92,16 +93,16 @@ func (s *RepositoriesService) ListCommitActivity(owner, repo string) ([]*WeeklyC
}
var weeklyCommitActivity []*WeeklyCommitActivity
resp, err := s.client.Do(req, &weeklyCommitActivity)
resp, err := s.client.Do(ctx, req, &weeklyCommitActivity)
if err != nil {
return nil, resp, err
}
return weeklyCommitActivity, resp, err
return weeklyCommitActivity, resp, nil
}
// ListCodeFrequency returns a weekly aggregate of the number of additions and
// deletions pushed to a repository. Returned WeeklyStats will contain
// deletions pushed to a repository. Returned WeeklyStats will contain
// additions and deletions, but not total commits.
//
// If this is the first time these statistics are requested for the given
@ -110,8 +111,8 @@ func (s *RepositoriesService) ListCommitActivity(owner, repo string) ([]*WeeklyC
// it is now computing the requested statistics. A follow up request, after a
// delay of a second or so, should result in a successful request.
//
// GitHub API Docs: https://developer.github.com/v3/repos/statistics/#code-frequency
func (s *RepositoriesService) ListCodeFrequency(owner, repo string) ([]*WeeklyStats, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/statistics/#code-frequency
func (s *RepositoriesService) ListCodeFrequency(ctx context.Context, owner, repo string) ([]*WeeklyStats, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/stats/code_frequency", owner, repo)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@ -119,7 +120,7 @@ func (s *RepositoriesService) ListCodeFrequency(owner, repo string) ([]*WeeklySt
}
var weeks [][]int
resp, err := s.client.Do(req, &weeks)
resp, err := s.client.Do(ctx, req, &weeks)
// convert int slices into WeeklyStats
var stats []*WeeklyStats
@ -163,8 +164,8 @@ func (r RepositoryParticipation) String() string {
// it is now computing the requested statistics. A follow up request, after a
// delay of a second or so, should result in a successful request.
//
// GitHub API Docs: https://developer.github.com/v3/repos/statistics/#participation
func (s *RepositoriesService) ListParticipation(owner, repo string) (*RepositoryParticipation, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/statistics/#participation
func (s *RepositoriesService) ListParticipation(ctx context.Context, owner, repo string) (*RepositoryParticipation, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/stats/participation", owner, repo)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@ -172,12 +173,12 @@ func (s *RepositoriesService) ListParticipation(owner, repo string) (*Repository
}
participation := new(RepositoryParticipation)
resp, err := s.client.Do(req, participation)
resp, err := s.client.Do(ctx, req, participation)
if err != nil {
return nil, resp, err
}
return participation, resp, err
return participation, resp, nil
}
// PunchCard represents the number of commits made during a given hour of a
@ -196,8 +197,8 @@ type PunchCard struct {
// it is now computing the requested statistics. A follow up request, after a
// delay of a second or so, should result in a successful request.
//
// GitHub API Docs: https://developer.github.com/v3/repos/statistics/#punch-card
func (s *RepositoriesService) ListPunchCard(owner, repo string) ([]*PunchCard, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/statistics/#punch-card
func (s *RepositoriesService) ListPunchCard(ctx context.Context, owner, repo string) ([]*PunchCard, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/stats/punch_card", owner, repo)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@ -205,7 +206,7 @@ func (s *RepositoriesService) ListPunchCard(owner, repo string) ([]*PunchCard, *
}
var results [][]int
resp, err := s.client.Do(req, &results)
resp, err := s.client.Do(ctx, req, &results)
// convert int slices into Punchcards
var cards []*PunchCard