-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the protected branch panic issue #3567
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3567 +/- ##
==========================================
+ Coverage 35.79% 35.79% +<.01%
==========================================
Files 285 285
Lines 40863 40866 +3
==========================================
+ Hits 14625 14630 +5
+ Misses 24068 24066 -2
Partials 2170 2170
Continue to review full report at Codecov.
|
routers/repo/branch.go
Outdated
if err != nil { | ||
ctx.ServerError("IsProtectedBranch", err) | ||
return nil | ||
var isProtected bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isProtected maybe default true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to add a check before
Line 167 in 19bf4dd
return !protectedBranch.CanUserPush(doer.ID), nil |
If we are here and user is nil -> return true, nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fix this for any use case of IsProtectedBranch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I thought so once, but the bad thing is the IsProtectedBranch function will be invoked multi-times redundantly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So simply do at start of func as it would be the same.
if doer == nil {
return true, nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I updated, thanks.
db8ae5d
to
c0c3683
Compare
I think this should be backported to |
Signed-off-by: Wendell Sun <iwendellsun@gmail.com>
Fixes #3326