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

@ -7,6 +7,7 @@ package github
import (
"bytes"
"context"
"fmt"
"time"
)
@ -107,8 +108,8 @@ type CommitsListOptions struct {
// ListCommits lists the commits of a repository.
//
// GitHub API docs: http://developer.github.com/v3/repos/commits/#list
func (s *RepositoriesService) ListCommits(owner, repo string, opt *CommitsListOptions) ([]*RepositoryCommit, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/commits/#list
func (s *RepositoriesService) ListCommits(ctx context.Context, owner, repo string, opt *CommitsListOptions) ([]*RepositoryCommit, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/commits", owner, repo)
u, err := addOptions(u, opt)
if err != nil {
@ -120,21 +121,21 @@ func (s *RepositoriesService) ListCommits(owner, repo string, opt *CommitsListOp
return nil, nil, err
}
commits := new([]*RepositoryCommit)
resp, err := s.client.Do(req, commits)
var commits []*RepositoryCommit
resp, err := s.client.Do(ctx, req, &commits)
if err != nil {
return nil, resp, err
}
return *commits, resp, err
return commits, resp, nil
}
// GetCommit fetches the specified commit, including all details about it.
// todo: support media formats - https://github.com/google/go-github/issues/6
//
// GitHub API docs: http://developer.github.com/v3/repos/commits/#get-a-single-commit
// See also: http://developer.github.com//v3/git/commits/#get-a-single-commit provides the same functionality
func (s *RepositoriesService) GetCommit(owner, repo, sha string) (*RepositoryCommit, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/commits/#get-a-single-commit
// See also: https://developer.github.com//v3/git/commits/#get-a-single-commit provides the same functionality
func (s *RepositoriesService) GetCommit(ctx context.Context, owner, repo, sha string) (*RepositoryCommit, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha)
req, err := s.client.NewRequest("GET", u, nil)
@ -146,19 +147,19 @@ func (s *RepositoriesService) GetCommit(owner, repo, sha string) (*RepositoryCom
req.Header.Set("Accept", mediaTypeGitSigningPreview)
commit := new(RepositoryCommit)
resp, err := s.client.Do(req, commit)
resp, err := s.client.Do(ctx, req, commit)
if err != nil {
return nil, resp, err
}
return commit, resp, err
return commit, resp, nil
}
// GetCommitSHA1 gets the SHA-1 of a commit reference. If a last-known SHA1 is
// GetCommitSHA1 gets the SHA-1 of a commit reference. If a last-known SHA1 is
// supplied and no new commits have occurred, a 304 Unmodified response is returned.
//
// GitHub API docs: https://developer.github.com/v3/repos/commits/#get-the-sha-1-of-a-commit-reference
func (s *RepositoriesService) GetCommitSHA1(owner, repo, ref, lastSHA string) (string, *Response, error) {
func (s *RepositoriesService) GetCommitSHA1(ctx context.Context, owner, repo, ref, lastSHA string) (string, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, ref)
req, err := s.client.NewRequest("GET", u, nil)
@ -172,19 +173,19 @@ func (s *RepositoriesService) GetCommitSHA1(owner, repo, ref, lastSHA string) (s
req.Header.Set("Accept", mediaTypeV3SHA)
var buf bytes.Buffer
resp, err := s.client.Do(req, &buf)
resp, err := s.client.Do(ctx, req, &buf)
if err != nil {
return "", resp, err
}
return buf.String(), resp, err
return buf.String(), resp, nil
}
// CompareCommits compares a range of commits with each other.
// todo: support media formats - https://github.com/google/go-github/issues/6
//
// GitHub API docs: http://developer.github.com/v3/repos/commits/index.html#compare-two-commits
func (s *RepositoriesService) CompareCommits(owner, repo string, base, head string) (*CommitsComparison, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/repos/commits/index.html#compare-two-commits
func (s *RepositoriesService) CompareCommits(ctx context.Context, owner, repo string, base, head string) (*CommitsComparison, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/compare/%v...%v", owner, repo, base, head)
req, err := s.client.NewRequest("GET", u, nil)
@ -193,10 +194,10 @@ func (s *RepositoriesService) CompareCommits(owner, repo string, base, head stri
}
comp := new(CommitsComparison)
resp, err := s.client.Do(req, comp)
resp, err := s.client.Do(ctx, req, comp)
if err != nil {
return nil, resp, err
}
return comp, resp, err
return comp, resp, nil
}