mirror of
https://github.com/go-gitea/gitea
synced 2025-08-12 04:28:21 +00:00
Fix adding branch as protected to not allow pushing to it (#2556)
* Fix adding branch as protected to not allow pushing to it * Fix can_push value to false in protected_branch (#2560) * Fix integration test
This commit is contained in:
14
cmd/hook.go
14
cmd/hook.go
@@ -127,14 +127,12 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
}
|
||||
|
||||
if protectBranch != nil {
|
||||
if !protectBranch.CanPush {
|
||||
// check and deletion
|
||||
if newCommitID == git.EmptySHA {
|
||||
fail(fmt.Sprintf("branch %s is protected from deletion", branchName), "")
|
||||
} else {
|
||||
fail(fmt.Sprintf("protected branch %s can not be pushed to", branchName), "")
|
||||
//fail(fmt.Sprintf("branch %s is protected from force push", branchName), "")
|
||||
}
|
||||
// check and deletion
|
||||
if newCommitID == git.EmptySHA {
|
||||
fail(fmt.Sprintf("branch %s is protected from deletion", branchName), "")
|
||||
} else if !protectBranch.CanPush {
|
||||
fail(fmt.Sprintf("protected branch %s can not be pushed to", branchName), "")
|
||||
//fail(fmt.Sprintf("branch %s is protected from force push", branchName), "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user