Skip to content

Commit 832a08c

Browse files
committed
Document required branch protection fields.
All of those fields are documented as required at https://developer.github.com/v3/repos/branches/#update-branch-protection. In #512, we changed the API to better reflect that. However, it should still be documented that the fields are required. This is consistent with the other required fields that are also documented as required. Additionally, note that empty slices must be non-nil. From running integration tests, I've seen that passing nil slices (which get encoded as null via encoding/json) resulted in invalid request errors such as: No subschema in "anyOf" matched. For 'properties/users', nil is not an array. For 'properties/teams', nil is not an array. Not all subschemas of "allOf" matched. For 'anyOf/1', {"users"=>nil, "teams"=>nil} is not a null. [] Follows #512.
1 parent cec1afe commit 832a08c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

github/repos.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,18 @@ type ProtectionRequest struct {
522522

523523
// RequiredStatusChecks represents the protection status of a individual branch.
524524
type RequiredStatusChecks struct {
525-
// Enforce required status checks for repository administrators.
525+
// Enforce required status checks for repository administrators. (Required.)
526526
IncludeAdmins bool `json:"include_admins"`
527-
// Require branches to be up to date before merging.
527+
// Require branches to be up to date before merging. (Required.)
528528
Strict bool `json:"strict"`
529529
// The list of status checks to require in order to merge into this
530-
// branch.
530+
// branch. (Required; use []string{} instead of nil for empty list.)
531531
Contexts []string `json:"contexts"`
532532
}
533533

534534
// RequiredPullRequestReviews represents the protection configuration for pull requests.
535535
type RequiredPullRequestReviews struct {
536-
// Enforce pull request reviews for repository administrators.
536+
// Enforce pull request reviews for repository administrators. (Required.)
537537
IncludeAdmins bool `json:"include_admins"`
538538
}
539539

@@ -551,9 +551,9 @@ type BranchRestrictions struct {
551551
// separate from BranchRestrictions above because the request structure is
552552
// different from the response structure.
553553
type BranchRestrictionsRequest struct {
554-
// The list of user logins with push access.
554+
// The list of user logins with push access. (Required; use []string{} instead of nil for empty list.)
555555
Users []string `json:"users"`
556-
// The list of team slugs with push access.
556+
// The list of team slugs with push access. (Required; use []string{} instead of nil for empty list.)
557557
Teams []string `json:"teams"`
558558
}
559559

0 commit comments

Comments
 (0)