mirror of
https://github.com/gogs/gogs.git
synced 2025-05-31 11:42:13 +00:00
Protected branches: allow whitelist bypass require pull request check (#4207)
This commit is contained in:
parent
e38fef0009
commit
83f6b8e847
15
cmd/hook.go
15
cmd/hook.go
@ -100,14 +100,21 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if whitelist is enabled
|
||||
// Whitelist users can bypass require pull request check
|
||||
bypassRequirePullReuqest := false
|
||||
|
||||
// Check if user is in whitelist when enabled
|
||||
userID := com.StrTo(os.Getenv(http.ENV_AUTH_USER_ID)).MustInt64()
|
||||
if protectBranch.EnableWhitelist && !models.IsUserInProtectBranchWhitelist(repoID, userID, branchName) {
|
||||
fail(fmt.Sprintf("Branch '%s' is protected and you are not in the push whitelist", branchName), "")
|
||||
if protectBranch.EnableWhitelist {
|
||||
if !models.IsUserInProtectBranchWhitelist(repoID, userID, branchName) {
|
||||
fail(fmt.Sprintf("Branch '%s' is protected and you are not in the push whitelist", branchName), "")
|
||||
}
|
||||
|
||||
bypassRequirePullReuqest = true
|
||||
}
|
||||
|
||||
// Check if branch allows direct push
|
||||
if protectBranch.RequirePullRequest {
|
||||
if !bypassRequirePullReuqest && protectBranch.RequirePullRequest {
|
||||
fail(fmt.Sprintf("Branch '%s' is protected and commits must be merged through pull request", branchName), "")
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,7 @@ settings.protect_this_branch_desc = Disable force pushes and prevent from deleti
|
||||
settings.protect_require_pull_request = Require pull request instead direct pushing
|
||||
settings.protect_require_pull_request_desc = Enable this option to disable direct pushing to this branch. Commits have to be pushed to another non-protected branch and merged to this branch through pull request.
|
||||
settings.protect_whitelist_committers = Whitelist who can push to this branch
|
||||
settings.protect_whitelist_committers_desc = Add people or teams to whitelist of direct push to this branch.
|
||||
settings.protect_whitelist_committers_desc = Add people or teams to whitelist of direct push to this branch. Users in whitelist will bypass require pull request check.
|
||||
settings.protect_whitelist_users = Users who can push to this branch
|
||||
settings.protect_whitelist_search_users = Search users
|
||||
settings.protect_whitelist_teams = Teams for which members of them can push to this branch
|
||||
|
2
gogs.go
2
gogs.go
@ -16,7 +16,7 @@ import (
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.10.8.0307"
|
||||
const APP_VER = "0.10.8.0308"
|
||||
|
||||
func init() {
|
||||
setting.AppVer = APP_VER
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
0.10.8.0307
|
||||
0.10.8.0308
|
@ -46,7 +46,7 @@
|
||||
{{range .Users}}
|
||||
<div class="item" data-value="{{.ID}}">
|
||||
<img class="ui mini image" src="{{.RelAvatarLink}}">
|
||||
{{.DisplayName}}
|
||||
{{.Name}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user