catch error (#736)

This commit is contained in:
laurentsimon 2021-07-22 15:00:12 -07:00 committed by GitHub
parent a1502dd51a
commit f021326e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,10 +155,8 @@ func isBranchProtected(branches []*github.Branch, name string) (bool, error) {
func getProtectionAndCheck(ctx context.Context, r repositories, dl checker.DetailLogger, ownerStr, repoStr,
branch string) checker.CheckResult {
// We only call this if the branch is protected. An error indicates not found.
protection, resp, err := r.GetBranchProtection(ctx, ownerStr, repoStr, branch)
const fileNotFound = 404
if resp.StatusCode == fileNotFound {
protection, _, err := r.GetBranchProtection(ctx, ownerStr, repoStr, branch)
if err != nil {
e := sce.Create(sce.ErrScorecardInternal, err.Error())
return checker.CreateRuntimeErrorResult(CheckBranchProtection, e)
}