Skip to content

Commit 8292762

Browse files
victoryNapgmlewis
authored andcommitted
Add RequiredApprovingReviewCount to PullRequestReviewsEnforcement (#880)
1 parent 5d3c7cb commit 8292762

File tree

4 files changed

+136
-44
lines changed

4 files changed

+136
-44
lines changed

github/github.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ const (
4848
// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
4949
mediaTypeStarringPreview = "application/vnd.github.v3.star+json"
5050

51-
// https://developer.github.com/changes/2015-11-11-protected-branches-api/
52-
mediaTypeProtectedBranchesPreview = "application/vnd.github.loki-preview+json"
53-
5451
// https://help.github.com/enterprise/2.4/admin/guides/migrations/exporting-the-github-com-organization-s-repositories/
5552
mediaTypeMigrationsPreview = "application/vnd.github.wyandotte-preview+json"
5653

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

105+
// https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/
106+
mediaTypeRequiredApprovingReviewsPreview = "application/vnd.github.luke-cage-preview+json"
107+
108108
// https://developer.github.com/changes/2018-02-22-label-description-search-preview/
109109
mediaTypeLabelDescriptionSearchPreview = "application/vnd.github.symmetra-preview+json"
110110

github/repos.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@ type PullRequestReviewsEnforcement struct {
568568
DismissStaleReviews bool `json:"dismiss_stale_reviews"`
569569
// RequireCodeOwnerReviews specifies if an approved review is required in pull requests including files with a designated code owner.
570570
RequireCodeOwnerReviews bool `json:"require_code_owner_reviews"`
571+
// RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged.
572+
// Valid values are 1-6.
573+
RequiredApprovingReviewCount int `json:"required_approving_review_count"`
571574
}
572575

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

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

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

660669
// TODO: remove custom Accept header when this API fully launches
661-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
670+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
662671

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

682691
// TODO: remove custom Accept header when this API fully launches
683-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
692+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
684693

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

704713
// TODO: remove custom Accept header when this API fully launches
705-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
714+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
706715

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

726735
// TODO: remove custom Accept header when this API fully launches
727-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
736+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
728737

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

748757
// TODO: remove custom Accept header when this API fully launches
749-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
758+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
750759

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

769778
// TODO: remove custom Accept header when this API fully launches
770-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
779+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
771780

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

791800
// TODO: remove custom Accept header when this API fully launches
792-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
801+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
793802

794803
return s.client.Do(ctx, req, nil)
795804
}
@@ -843,7 +852,7 @@ func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Contex
843852
}
844853

845854
// TODO: remove custom Accept header when this API fully launches
846-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
855+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
847856

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

868877
// TODO: remove custom Accept header when this API fully launches
869-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
878+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
870879

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

896905
// TODO: remove custom Accept header when this API fully launches
897-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
906+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
898907

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

918927
// TODO: remove custom Accept header when this API fully launches
919-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
928+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
920929

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

934943
// TODO: remove custom Accept header when this API fully launches
935-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
944+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
936945

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

957966
// TODO: remove custom Accept header when this API fully launches
958-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
967+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
959968

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

979988
// TODO: remove custom Accept header when this API fully launches
980-
req.Header.Set("Accept", mediaTypeProtectedBranchesPreview)
989+
req.Header.Set("Accept", mediaTypeRequiredApprovingReviewsPreview)
981990

982991
return s.client.Do(ctx, req, nil)
983992
}

0 commit comments

Comments
 (0)