You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling the GitHub API endpoint https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_signatures(documentation), if the branch does not have any protection rules, the GitHub API will reply with a HTTP 404 Not Found code and the following body:
{
"message": "Branch not protected",
"documentation_url": "https://docs.github.com/rest/branches/branch-protection#get-commit-signature-protection"
}
Other functions in go-github that may receive this kind of response usually manage it the following way:
I think this function should have the same behaviour, allowing callers to handle this case the same way as when calling say GetBranchProtection. Note that function isBranchNotProtected sounds like it would work without changes:
@cedricvanrompay-datadog - may I first say that this is one of the best issue messages I have ever read?
It is clear, to the point, and provides all the details needed with examples and a pointer to the problem.
Well done, and thank you very much!
Absolutely, I agree, and the issue is yours. Thanks again!
When calling the GitHub API endpoint
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_signatures
(documentation), if the branch does not have any protection rules, the GitHub API will reply with aHTTP 404 Not Found
code and the following body:Other functions in
go-github
that may receive this kind of response usually manage it the following way:go-github/github/repos.go
Lines 1347 to 1349 in 96726d8
However,
GetSignaturesProtectedBranch
does not:go-github/github/repos.go
Lines 1405 to 1409 in 96726d8
I think this function should have the same behaviour, allowing callers to handle this case the same way as when calling say
GetBranchProtection
. Note that functionisBranchNotProtected
sounds like it would work without changes:go-github/github/repos.go
Lines 2033 to 2036 in 96726d8
go-github/github/repos.go
Line 17 in 96726d8
I am happy to provide a Pull Request (should be trivial) for this.
The text was updated successfully, but these errors were encountered: