瀏覽代碼

Protected branches: allow whitelist bypass require pull request check (#4207)

Unknwon 8 年之前
父節點
當前提交
83f6b8e847
共有 6 個文件被更改,包括 21 次插入14 次删除
  1. 11 4
      cmd/hook.go
  2. 1 1
      conf/locale/locale_en-US.ini
  3. 1 1
      gogs.go
  4. 6 6
      modules/bindata/bindata.go
  5. 1 1
      templates/.VERSION
  6. 1 1
      templates/repo/settings/protected_branch.tmpl

+ 11 - 4
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), "")
 		}
 

+ 1 - 1
conf/locale/locale_en-US.ini

@@ -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

+ 1 - 1
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

文件差異過大導致無法顯示
+ 6 - 6
modules/bindata/bindata.go


+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.10.8.0307
+0.10.8.0308

+ 1 - 1
templates/repo/settings/protected_branch.tmpl

@@ -46,7 +46,7 @@
 												{{range .Users}}
 													<div class="item" data-value="{{.ID}}">
 														<img class="ui mini image" src="{{.RelAvatarLink}}">
-														{{.DisplayName}}
+														{{.Name}}
 													</div>
 												{{end}}
 											</div>

部分文件因文件數量過多而無法顯示