Skip to content

Commit 2782c14

Browse files
lunnyzeripath
andauthored
Supports wildcard protected branch (#20825)
This PR introduce glob match for protected branch name. The separator is `/` and you can use `*` matching non-separator chars and use `**` across separator. It also supports input an exist or non-exist branch name as matching condition and branch name condition has high priority than glob rule. Should fix #2529 and #15705 screenshots <img width="1160" alt="image" src="https://user-images.githubusercontent.com/81045/205651179-ebb5492a-4ade-4bb4-a13c-965e8c927063.png"> Co-authored-by: zeripath <[email protected]>
1 parent cc1f8cb commit 2782c14

39 files changed

+1217
-814
lines changed

models/git/branches.go

+15-415
Large diffs are not rendered by default.

models/git/branches_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ func TestRenameBranch(t *testing.T) {
105105
defer committer.Close()
106106
assert.NoError(t, err)
107107
assert.NoError(t, git_model.UpdateProtectBranch(ctx, repo1, &git_model.ProtectedBranch{
108-
RepoID: repo1.ID,
109-
BranchName: "master",
108+
RepoID: repo1.ID,
109+
RuleName: "master",
110110
}, git_model.WhitelistOptions{}))
111111
assert.NoError(t, committer.Commit())
112112

@@ -131,8 +131,8 @@ func TestRenameBranch(t *testing.T) {
131131
assert.Equal(t, int64(1), renamedBranch.RepoID)
132132

133133
unittest.AssertExistsAndLoadBean(t, &git_model.ProtectedBranch{
134-
RepoID: repo1.ID,
135-
BranchName: "main",
134+
RepoID: repo1.ID,
135+
RuleName: "main",
136136
})
137137
}
138138

0 commit comments

Comments
 (0)