1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 06:09:42 +02:00
Migrated from plain /vendor to go dep
This commit is contained in:
Harvey Kandola 2018-02-14 15:23:46 +00:00
parent 0262763c95
commit fd693f4ff4
957 changed files with 36866 additions and 177595 deletions

View file

@ -6,6 +6,7 @@
package github
import (
"context"
"fmt"
"time"
)
@ -39,13 +40,13 @@ func (w WeeklyStats) String() string {
// deletions and commit counts.
//
// If this is the first time these statistics are requested for the given
// repository, this method will return a non-nil error and a status code of
// 202. This is because this is the status that github returns to signify that
// repository, this method will return an *AcceptedError and a status code of
// 202. This is because this is the status that GitHub returns to signify that
// 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.
@ -78,13 +79,13 @@ func (w WeeklyCommitActivity) String() string {
// starting on Sunday.
//
// If this is the first time these statistics are requested for the given
// repository, this method will return a non-nil error and a status code of
// 202. This is because this is the status that github returns to signify that
// repository, this method will return an *AcceptedError and a status code of
// 202. This is because this is the status that GitHub returns to signify that
// 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,20 +93,26 @@ 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.
//
// GitHub API Docs: https://developer.github.com/v3/repos/statistics/#code-frequency
func (s *RepositoriesService) ListCodeFrequency(owner, repo string) ([]*WeeklyStats, *Response, error) {
// If this is the first time these statistics are requested for the given
// repository, this method will return an *AcceptedError and a status code of
// 202. This is because this is the status that GitHub returns to signify that
// 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(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 {
@ -113,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
@ -152,14 +159,13 @@ func (r RepositoryParticipation) String() string {
// The array order is oldest week (index 0) to most recent week.
//
// If this is the first time these statistics are requested for the given
// repository, this method will return a non-nil error and a status code
// of 202. This is because this is the status that github returns to
// signify that 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.
// repository, this method will return an *AcceptedError and a status code of
// 202. This is because this is the status that GitHub returns to signify that
// 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 {
@ -167,16 +173,16 @@ 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
// day of thew eek.
// day of the week.
type PunchCard struct {
Day *int // Day of the week (0-6: =Sunday - Saturday).
Hour *int // Hour of day (0-23).
@ -185,8 +191,14 @@ type PunchCard struct {
// ListPunchCard returns the number of commits per hour in each day.
//
// GitHub API Docs: https://developer.github.com/v3/repos/statistics/#punch-card
func (s *RepositoriesService) ListPunchCard(owner, repo string) ([]*PunchCard, *Response, error) {
// If this is the first time these statistics are requested for the given
// repository, this method will return an *AcceptedError and a status code of
// 202. This is because this is the status that GitHub returns to signify that
// 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(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 {
@ -194,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