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:
Unknwon
2017-02-23 18:25:12 -05:00
parent b78e03934d
commit 6072e9a52c
16 changed files with 290 additions and 40 deletions

View File

@@ -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), "")