Skip to content

Commit

Permalink
Supports wildcard protected branch (#20825)
Browse files Browse the repository at this point in the history
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 <art27@cantab.net>
  • Loading branch information
lunny and zeripath authored Jan 16, 2023
1 parent cc1f8cb commit 2782c14
Show file tree
Hide file tree
Showing 39 changed files with 1,217 additions and 814 deletions.
430 changes: 15 additions & 415 deletions models/git/branches.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions models/git/branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func TestRenameBranch(t *testing.T) {
defer committer.Close()
assert.NoError(t, err)
assert.NoError(t, git_model.UpdateProtectBranch(ctx, repo1, &git_model.ProtectedBranch{
RepoID: repo1.ID,
BranchName: "master",
RepoID: repo1.ID,
RuleName: "master",
}, git_model.WhitelistOptions{}))
assert.NoError(t, committer.Commit())

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

unittest.AssertExistsAndLoadBean(t, &git_model.ProtectedBranch{
RepoID: repo1.ID,
BranchName: "main",
RepoID: repo1.ID,
RuleName: "main",
})
}

Expand Down
Loading

0 comments on commit 2782c14

Please sign in to comment.