Skip to content

Commit

Permalink
Add RequiredApprovingReviewCount to PullRequestReviewsEnforcement (go…
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryNap authored and gmlewis committed Aug 10, 2018
1 parent 5d3c7cb commit 8292762
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 44 deletions.
6 changes: 3 additions & 3 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ const (
// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
mediaTypeStarringPreview = "application/vnd.github.v3.star+json"

// https://developer.github.com/changes/2015-11-11-protected-branches-api/
mediaTypeProtectedBranchesPreview = "application/vnd.github.loki-preview+json"

// https://help.github.com/enterprise/2.4/admin/guides/migrations/exporting-the-github-com-organization-s-repositories/
mediaTypeMigrationsPreview = "application/vnd.github.wyandotte-preview+json"

Expand Down Expand Up @@ -105,6 +102,9 @@ const (
// https://developer.github.com/changes/2018-01-25-organization-invitation-api-preview/
mediaTypeOrganizationInvitationPreview = "application/vnd.github.dazzler-preview+json"

// https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/
mediaTypeRequiredApprovingReviewsPreview = "application/vnd.github.luke-cage-preview+json"

// https://developer.github.com/changes/2018-02-22-label-description-search-preview/
mediaTypeLabelDescriptionSearchPreview = "application/vnd.github.symmetra-preview+json"

Expand Down
37 changes: 23 additions & 14 deletions github/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ type PullRequestReviewsEnforcement struct {
DismissStaleReviews bool `json:"dismiss_stale_reviews"`
// RequireCodeOwnerReviews specifies if an approved review is required in pull requests including files with a designated code owner.
RequireCodeOwnerReviews bool `json:"require_code_owner_reviews"`
// RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged.
// Valid values are 1-6.
RequiredApprovingReviewCount int `json:"required_approving_review_count"`
}

// PullRequestReviewsEnforcementRequest represents request to set the pull request review
Expand All @@ -582,6 +585,9 @@ type PullRequestReviewsEnforcementRequest struct {
DismissStaleReviews bool `json:"dismiss_stale_reviews"`
// RequireCodeOwnerReviews specifies if an approved review is required in pull requests including files with a designated code owner.
RequireCodeOwnerReviews bool `json:"require_code_owner_reviews"`
// RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged.
// Valid values are 1-6.
RequiredApprovingReviewCount int `json:"required_approving_review_count"`
}

// PullRequestReviewsEnforcementUpdate represents request to patch the pull request review
Expand All @@ -594,6 +600,9 @@ type PullRequestReviewsEnforcementUpdate struct {
DismissStaleReviews *bool `json:"dismiss_stale_reviews,omitempty"`
// RequireCodeOwnerReviews specifies if an approved review is required in pull requests including files with a designated code owner.
RequireCodeOwnerReviews bool `json:"require_code_owner_reviews,omitempty"`
// RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged.
// Valid values are 1 - 6.
RequiredApprovingReviewCount int `json:"required_approving_review_count"`
}

// AdminEnforcement represents the configuration to enforce required status checks for repository administrators.
Expand Down Expand Up @@ -658,7 +667,7 @@ func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, re
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

var branches []*Branch
resp, err := s.client.Do(ctx, req, &branches)
Expand All @@ -680,7 +689,7 @@ func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

b := new(Branch)
resp, err := s.client.Do(ctx, req, b)
Expand All @@ -702,7 +711,7 @@ func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, re
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

p := new(Protection)
resp, err := s.client.Do(ctx, req, p)
Expand All @@ -724,7 +733,7 @@ func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

p := new(RequiredStatusChecks)
resp, err := s.client.Do(ctx, req, p)
Expand All @@ -746,7 +755,7 @@ func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Conte
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

resp, err = s.client.Do(ctx, req, &contexts)
if err != nil {
Expand All @@ -767,7 +776,7 @@ func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner,
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

p := new(Protection)
resp, err := s.client.Do(ctx, req, p)
Expand All @@ -789,7 +798,7 @@ func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner,
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

return s.client.Do(ctx, req, nil)
}
Expand Down Expand Up @@ -843,7 +852,7 @@ func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Contex
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

r := new(PullRequestReviewsEnforcement)
resp, err := s.client.Do(ctx, req, r)
Expand All @@ -866,7 +875,7 @@ func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Con
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

r := new(PullRequestReviewsEnforcement)
resp, err := s.client.Do(ctx, req, r)
Expand Down Expand Up @@ -894,7 +903,7 @@ func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context,
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

r := new(PullRequestReviewsEnforcement)
resp, err := s.client.Do(ctx, req, r)
Expand All @@ -916,7 +925,7 @@ func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Con
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

return s.client.Do(ctx, req, nil)
}
Expand All @@ -932,7 +941,7 @@ func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, re
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

r := new(AdminEnforcement)
resp, err := s.client.Do(ctx, req, r)
Expand All @@ -955,7 +964,7 @@ func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, re
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

r := new(AdminEnforcement)
resp, err := s.client.Do(ctx, req, r)
Expand All @@ -977,7 +986,7 @@ func (s *RepositoriesService) RemoveAdminEnforcement(ctx context.Context, owner,
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)

return s.client.Do(ctx, req, nil)
}
Expand Down
Loading

0 comments on commit 8292762

Please sign in to comment.