mirror of
https://github.com/gogs/gogs.git
synced 2026-05-07 12:07:50 +02:00
repo: add protect branch whitelist (#4177)
Add options to add users and teams to whitelist of a protected branch. This is only available for organizational repositories.
This commit is contained in:
@@ -100,6 +100,12 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if whitelist is 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), "")
|
||||
}
|
||||
|
||||
// Check if branch allows direct push
|
||||
if protectBranch.RequirePullRequest {
|
||||
fail(fmt.Sprintf("Branch '%s' is protected and commits must be merged through pull request", branchName), "")
|
||||
|
||||
Reference in New Issue
Block a user