Repository navigation
Conversation
| RequiredPullRequestReviews *PullRequestReviewsEnforcement `json:"required_pull_request_reviews"` | ||
| EnforceAdmins *AdminEnforcement `json:"enforce_admins"` | ||
| Restrictions *BranchRestrictions `json:"restrictions"` | ||
| RequiredLinearHistory bool `json:"required_linear_history"` |
There was a problem hiding this comment.
Each of these three bool fields need to be structures with a single Enabled field, based on the GitHub v3 API developer docs found here:
https://developer.github.com/v3/repos/branches/#get-branch-protection
Here is the example output from this endpoint:
...
"required_linear_history": {
"enabled": true
},
"allow_force_pushes": {
"enabled": true
},
"allow_deletions": {
"enabled": true
}
Since each of these structs appear to only have a single Enabled field, I'm fine with making them all the same struct type... something like:
type EnabledType struct {
Enabled bool `json:"enabled"`
}
and then these three fields would have struct pointers with omitempty, like this:
RequiredLinearHistory *EnabledType `json:"required_linear_history,omitempty"`
AllowForcePushes *EnabledType `json:"allow_force_pushes,omitempty"`
AllowDeletions *EnabledType `json:"allow_deletions,omitempty"`
That way, if GitHub provides the values, great... but if not, we know that they weren't returned.
| RequiredPullRequestReviews *PullRequestReviewsEnforcementRequest `json:"required_pull_request_reviews"` | ||
| EnforceAdmins bool `json:"enforce_admins"` | ||
| Restrictions *BranchRestrictionsRequest `json:"restrictions"` | ||
| RequiredLinearHistory bool `json:"required_linear_history"` |
There was a problem hiding this comment.
Unfortunately, this won't work either. Because these are optional fields, these three need to be type *bool and not bool.
They also need the ,omiteempty flag on them
wesleimp
left a comment
There was a problem hiding this comment.
Sorry for my last review, I was a little bit confused about the docs. My bad
Fixes #1345