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

@ -5,7 +5,10 @@
package github
import "fmt"
import (
"context"
"fmt"
)
// RepositoryInvitation represents an invitation to collaborate on a repo.
type RepositoryInvitation struct {
@ -25,8 +28,8 @@ type RepositoryInvitation struct {
// ListInvitations lists all currently-open repository invitations.
//
// GitHub API docs: https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository
func (s *RepositoriesService) ListInvitations(repoID int, opt *ListOptions) ([]*RepositoryInvitation, *Response, error) {
u := fmt.Sprintf("repositories/%v/invitations", repoID)
func (s *RepositoriesService) ListInvitations(ctx context.Context, owner, repo string, opt *ListOptions) ([]*RepositoryInvitation, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/invitations", owner, repo)
u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
@ -41,19 +44,19 @@ func (s *RepositoriesService) ListInvitations(repoID int, opt *ListOptions) ([]*
req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview)
invites := []*RepositoryInvitation{}
resp, err := s.client.Do(req, &invites)
resp, err := s.client.Do(ctx, req, &invites)
if err != nil {
return nil, resp, err
}
return invites, resp, err
return invites, resp, nil
}
// DeleteInvitation deletes a repository invitation.
//
// GitHub API docs: https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation
func (s *RepositoriesService) DeleteInvitation(repoID, invitationID int) (*Response, error) {
u := fmt.Sprintf("repositories/%v/invitations/%v", repoID, invitationID)
func (s *RepositoriesService) DeleteInvitation(ctx context.Context, owner, repo string, invitationID int) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/invitations/%v", owner, repo, invitationID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
@ -62,7 +65,7 @@ func (s *RepositoriesService) DeleteInvitation(repoID, invitationID int) (*Respo
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview)
return s.client.Do(req, nil)
return s.client.Do(ctx, req, nil)
}
// UpdateInvitation updates the permissions associated with a repository
@ -72,11 +75,11 @@ func (s *RepositoriesService) DeleteInvitation(repoID, invitationID int) (*Respo
// on the repository. Possible values are: "read", "write", "admin".
//
// GitHub API docs: https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation
func (s *RepositoriesService) UpdateInvitation(repoID, invitationID int, permissions string) (*RepositoryInvitation, *Response, error) {
func (s *RepositoriesService) UpdateInvitation(ctx context.Context, owner, repo string, invitationID int, permissions string) (*RepositoryInvitation, *Response, error) {
opts := &struct {
Permissions string `json:"permissions"`
}{Permissions: permissions}
u := fmt.Sprintf("repositories/%v/invitations/%v", repoID, invitationID)
u := fmt.Sprintf("repos/%v/%v/invitations/%v", owner, repo, invitationID)
req, err := s.client.NewRequest("PATCH", u, opts)
if err != nil {
return nil, nil, err
@ -86,6 +89,6 @@ func (s *RepositoriesService) UpdateInvitation(repoID, invitationID int, permiss
req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview)
invite := &RepositoryInvitation{}
resp, err := s.client.Do(req, invite)
resp, err := s.client.Do(ctx, req, invite)
return invite, resp, err
}