aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/repos.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/google/go-github/github/repos.go')
-rw-r--r--vendor/github.com/google/go-github/github/repos.go100
1 files changed, 54 insertions, 46 deletions
diff --git a/vendor/github.com/google/go-github/github/repos.go b/vendor/github.com/google/go-github/github/repos.go
index 040cd31..019a731 100644
--- a/vendor/github.com/google/go-github/github/repos.go
+++ b/vendor/github.com/google/go-github/github/repos.go
@@ -175,13 +175,13 @@ func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]*
// TODO: remove custom Accept header when license support fully launches
req.Header.Set("Accept", mediaTypeLicensesPreview)
- repos := new([]*Repository)
- resp, err := s.client.Do(req, repos)
+ var repos []*Repository
+ resp, err := s.client.Do(req, &repos)
if err != nil {
return nil, resp, err
}
- return *repos, resp, err
+ return repos, resp, nil
}
// RepositoryListByOrgOptions specifies the optional parameters to the
@@ -212,13 +212,13 @@ func (s *RepositoriesService) ListByOrg(org string, opt *RepositoryListByOrgOpti
// TODO: remove custom Accept header when license support fully launches
req.Header.Set("Accept", mediaTypeLicensesPreview)
- repos := new([]*Repository)
- resp, err := s.client.Do(req, repos)
+ var repos []*Repository
+ resp, err := s.client.Do(req, &repos)
if err != nil {
return nil, resp, err
}
- return *repos, resp, err
+ return repos, resp, nil
}
// RepositoryListAllOptions specifies the optional parameters to the
@@ -244,13 +244,13 @@ func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]*Reposit
return nil, nil, err
}
- repos := new([]*Repository)
- resp, err := s.client.Do(req, repos)
+ var repos []*Repository
+ resp, err := s.client.Do(req, &repos)
if err != nil {
return nil, resp, err
}
- return *repos, resp, err
+ return repos, resp, nil
}
// Create a new repository. If an organization is specified, the new
@@ -277,7 +277,7 @@ func (s *RepositoriesService) Create(org string, repo *Repository) (*Repository,
return nil, resp, err
}
- return r, resp, err
+ return r, resp, nil
}
// Get fetches a repository.
@@ -301,7 +301,7 @@ func (s *RepositoriesService) Get(owner, repo string) (*Repository, *Response, e
return nil, resp, err
}
- return repository, resp, err
+ return repository, resp, nil
}
// GetByID fetches a repository.
@@ -324,7 +324,7 @@ func (s *RepositoriesService) GetByID(id int) (*Repository, *Response, error) {
return nil, resp, err
}
- return repository, resp, err
+ return repository, resp, nil
}
// Edit updates a repository.
@@ -346,7 +346,7 @@ func (s *RepositoriesService) Edit(owner, repo string, repository *Repository) (
return nil, resp, err
}
- return r, resp, err
+ return r, resp, nil
}
// Delete a repository.
@@ -408,13 +408,13 @@ func (s *RepositoriesService) ListContributors(owner string, repository string,
return nil, nil, err
}
- contributor := new([]*Contributor)
- resp, err := s.client.Do(req, contributor)
+ var contributor []*Contributor
+ resp, err := s.client.Do(req, &contributor)
if err != nil {
return nil, nil, err
}
- return *contributor, resp, err
+ return contributor, resp, nil
}
// ListLanguages lists languages for the specified repository. The returned map
@@ -440,7 +440,7 @@ func (s *RepositoriesService) ListLanguages(owner string, repo string) (map[stri
return nil, resp, err
}
- return languages, resp, err
+ return languages, resp, nil
}
// ListTeams lists the teams for the specified repository.
@@ -458,13 +458,13 @@ func (s *RepositoriesService) ListTeams(owner string, repo string, opt *ListOpti
return nil, nil, err
}
- teams := new([]*Team)
- resp, err := s.client.Do(req, teams)
+ var teams []*Team
+ resp, err := s.client.Do(req, &teams)
if err != nil {
return nil, resp, err
}
- return *teams, resp, err
+ return teams, resp, nil
}
// RepositoryTag represents a repository tag.
@@ -490,13 +490,13 @@ func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptio
return nil, nil, err
}
- tags := new([]*RepositoryTag)
- resp, err := s.client.Do(req, tags)
+ var tags []*RepositoryTag
+ resp, err := s.client.Do(req, &tags)
if err != nil {
return nil, resp, err
}
- return *tags, resp, err
+ return tags, resp, nil
}
// Branch represents a repository branch
@@ -508,34 +508,42 @@ type Branch struct {
// Protection represents a repository branch's protection.
type Protection struct {
- RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"`
- Restrictions *BranchRestrictions `json:"restrictions"`
+ RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"`
+ RequiredPullRequestReviews *RequiredPullRequestReviews `json:"required_pull_request_reviews"`
+ Restrictions *BranchRestrictions `json:"restrictions"`
}
// ProtectionRequest represents a request to create/edit a branch's protection.
type ProtectionRequest struct {
- RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"`
- Restrictions *BranchRestrictionsRequest `json:"restrictions"`
+ RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"`
+ RequiredPullRequestReviews *RequiredPullRequestReviews `json:"required_pull_request_reviews"`
+ Restrictions *BranchRestrictionsRequest `json:"restrictions"`
}
// RequiredStatusChecks represents the protection status of a individual branch.
type RequiredStatusChecks struct {
- // Enforce required status checks for repository administrators.
- IncludeAdmins *bool `json:"include_admins,omitempty"`
- // Require branches to be up to date before merging.
- Strict *bool `json:"strict,omitempty"`
+ // Enforce required status checks for repository administrators. (Required.)
+ IncludeAdmins bool `json:"include_admins"`
+ // Require branches to be up to date before merging. (Required.)
+ Strict bool `json:"strict"`
// The list of status checks to require in order to merge into this
- // branch.
- Contexts *[]string `json:"contexts,omitempty"`
+ // branch. (Required; use []string{} instead of nil for empty list.)
+ Contexts []string `json:"contexts"`
+}
+
+// RequiredPullRequestReviews represents the protection configuration for pull requests.
+type RequiredPullRequestReviews struct {
+ // Enforce pull request reviews for repository administrators. (Required.)
+ IncludeAdmins bool `json:"include_admins"`
}
// BranchRestrictions represents the restriction that only certain users or
// teams may push to a branch.
type BranchRestrictions struct {
// The list of user logins with push access.
- Users []*User `json:"users,omitempty"`
+ Users []*User `json:"users"`
// The list of team slugs with push access.
- Teams []*Team `json:"teams,omitempty"`
+ Teams []*Team `json:"teams"`
}
// BranchRestrictionsRequest represents the request to create/edit the
@@ -543,10 +551,10 @@ type BranchRestrictions struct {
// separate from BranchRestrictions above because the request structure is
// different from the response structure.
type BranchRestrictionsRequest struct {
- // The list of user logins with push access.
- Users *[]string `json:"users,omitempty"`
- // The list of team slugs with push access.
- Teams *[]string `json:"teams,omitempty"`
+ // The list of user logins with push access. (Required; use []string{} instead of nil for empty list.)
+ Users []string `json:"users"`
+ // The list of team slugs with push access. (Required; use []string{} instead of nil for empty list.)
+ Teams []string `json:"teams"`
}
// ListBranches lists branches for the specified repository.
@@ -567,13 +575,13 @@ func (s *RepositoriesService) ListBranches(owner string, repo string, opt *ListO
// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
- branches := new([]*Branch)
- resp, err := s.client.Do(req, branches)
+ var branches []*Branch
+ resp, err := s.client.Do(req, &branches)
if err != nil {
return nil, resp, err
}
- return *branches, resp, err
+ return branches, resp, nil
}
// GetBranch gets the specified branch for a repository.
@@ -595,7 +603,7 @@ func (s *RepositoriesService) GetBranch(owner, repo, branch string) (*Branch, *R
return nil, resp, err
}
- return b, resp, err
+ return b, resp, nil
}
// GetBranchProtection gets the protection of a given branch.
@@ -617,7 +625,7 @@ func (s *RepositoriesService) GetBranchProtection(owner, repo, branch string) (*
return nil, resp, err
}
- return p, resp, err
+ return p, resp, nil
}
// UpdateBranchProtection updates the protection of a given branch.
@@ -639,7 +647,7 @@ func (s *RepositoriesService) UpdateBranchProtection(owner, repo, branch string,
return nil, resp, err
}
- return p, resp, err
+ return p, resp, nil
}
// RemoveBranchProtection removes the protection of a given branch.
@@ -674,5 +682,5 @@ func (s *RepositoriesService) License(owner, repo string) (*RepositoryLicense, *
return nil, resp, err
}
- return r, resp, err
+ return r, resp, nil
}