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"
)
@ -13,7 +14,7 @@ import (
// OrganizationsService provides access to the organization related functions
// in the GitHub API.
//
// GitHub API docs: http://developer.github.com/v3/orgs/
// GitHub API docs: https://developer.github.com/v3/orgs/
type OrganizationsService service
// Organization represents a GitHub organization account.
@ -57,7 +58,7 @@ func (o Organization) String() string {
return Stringify(o)
}
// Plan represents the payment plan for an account. See plans at https://github.com/plans.
// Plan represents the payment plan for an account. See plans at https://github.com/plans.
type Plan struct {
Name *string `json:"name,omitempty"`
Space *int `json:"space,omitempty"`
@ -85,7 +86,7 @@ type OrganizationsListOptions struct {
// as the opts.Since parameter for the next call.
//
// GitHub API docs: https://developer.github.com/v3/orgs/#list-all-organizations
func (s *OrganizationsService) ListAll(opt *OrganizationsListOptions) ([]*Organization, *Response, error) {
func (s *OrganizationsService) ListAll(ctx context.Context, opt *OrganizationsListOptions) ([]*Organization, *Response, error) {
u, err := addOptions("organizations", opt)
if err != nil {
return nil, nil, err
@ -97,18 +98,18 @@ func (s *OrganizationsService) ListAll(opt *OrganizationsListOptions) ([]*Organi
}
orgs := []*Organization{}
resp, err := s.client.Do(req, &orgs)
resp, err := s.client.Do(ctx, req, &orgs)
if err != nil {
return nil, resp, err
}
return orgs, resp, err
return orgs, resp, nil
}
// List the organizations for a user. Passing the empty string will list
// List the organizations for a user. Passing the empty string will list
// organizations for the authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/orgs/#list-user-organizations
func (s *OrganizationsService) List(user string, opt *ListOptions) ([]*Organization, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/orgs/#list-user-organizations
func (s *OrganizationsService) List(ctx context.Context, user string, opt *ListOptions) ([]*Organization, *Response, error) {
var u string
if user != "" {
u = fmt.Sprintf("users/%v/orgs", user)
@ -125,19 +126,19 @@ func (s *OrganizationsService) List(user string, opt *ListOptions) ([]*Organizat
return nil, nil, err
}
orgs := new([]*Organization)
resp, err := s.client.Do(req, orgs)
var orgs []*Organization
resp, err := s.client.Do(ctx, req, &orgs)
if err != nil {
return nil, resp, err
}
return *orgs, resp, err
return orgs, resp, nil
}
// Get fetches an organization by name.
//
// GitHub API docs: http://developer.github.com/v3/orgs/#get-an-organization
func (s *OrganizationsService) Get(org string) (*Organization, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/orgs/#get-an-organization
func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organization, *Response, error) {
u := fmt.Sprintf("orgs/%v", org)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@ -145,18 +146,18 @@ func (s *OrganizationsService) Get(org string) (*Organization, *Response, error)
}
organization := new(Organization)
resp, err := s.client.Do(req, organization)
resp, err := s.client.Do(ctx, req, organization)
if err != nil {
return nil, resp, err
}
return organization, resp, err
return organization, resp, nil
}
// Edit an organization.
//
// GitHub API docs: http://developer.github.com/v3/orgs/#edit-an-organization
func (s *OrganizationsService) Edit(name string, org *Organization) (*Organization, *Response, error) {
// GitHub API docs: https://developer.github.com/v3/orgs/#edit-an-organization
func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error) {
u := fmt.Sprintf("orgs/%v", name)
req, err := s.client.NewRequest("PATCH", u, org)
if err != nil {
@ -164,10 +165,10 @@ func (s *OrganizationsService) Edit(name string, org *Organization) (*Organizati
}
o := new(Organization)
resp, err := s.client.Do(req, o)
resp, err := s.client.Do(ctx, req, o)
if err != nil {
return nil, resp, err
}
return o, resp, err
return o, resp, nil
}