Skip to content

Commit e7c2231

Browse files
Support for status check pattern (#24633)
This PR is to allow users to specify status checks by patterns. Users can enter patterns in the "Status Check Pattern" `textarea` to match status checks and each line specifies a pattern. If "Status Check" is enabled, patterns cannot be empty and user must enter at least one pattern. Users will no longer be able to choose status checks from the table. But a __*`Matched`*__ mark will be added to the matched checks to help users enter patterns. Benefits: - Even if no status checks have been completed, users can specify necessary status checks in advance. - More flexible. Users can specify a series of status checks by one pattern. Before: ![image](https://github.com/go-gitea/gitea/assets/15528715/635738ad-580c-49cd-941d-c721e5b99be4) After: ![image](https://github.com/go-gitea/gitea/assets/15528715/16aa7b1b-abf1-4170-9bfa-ae6fc9803a82) --------- Co-authored-by: silverwind <[email protected]>
1 parent 9fb0945 commit e7c2231

File tree

10 files changed

+267
-78
lines changed

10 files changed

+267
-78
lines changed

options/locale/locale_en-US.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2190,8 +2190,13 @@ settings.protect_merge_whitelist_committers_desc = Allow only whitelisted users
21902190
settings.protect_merge_whitelist_users = Whitelisted users for merging:
21912191
settings.protect_merge_whitelist_teams = Whitelisted teams for merging:
21922192
settings.protect_check_status_contexts = Enable Status Check
2193-
settings.protect_check_status_contexts_desc = Require status checks to pass before merging. Choose which status checks must pass before branches can be merged into a branch that matches this rule. When enabled, commits must first be pushed to another branch, then merged or pushed directly to a branch that matches this rule after status checks have passed. If no contexts are selected, the last commit must be successful regardless of context.
2193+
settings.protect_status_check_patterns = Status check patterns:
2194+
settings.protect_status_check_patterns_desc = Enter patterns to specify which status checks must pass before branches can be merged into a branch that matches this rule. Each line specifies a pattern. Patterns cannot be empty.
2195+
settings.protect_check_status_contexts_desc = Require status checks to pass before merging. When enabled, commits must first be pushed to another branch, then merged or pushed directly to a branch that matches this rule after status checks have passed. If no contexts are matched, the last commit must be successful regardless of context.
21942196
settings.protect_check_status_contexts_list = Status checks found in the last week for this repository
2197+
settings.protect_status_check_matched = Matched
2198+
settings.protect_invalid_status_check_pattern = Invalid status check pattern: "%s".
2199+
settings.protect_no_valid_status_check_patterns = No valid status check patterns.
21952200
settings.protect_required_approvals = Required approvals:
21962201
settings.protect_required_approvals_desc = Allow only to merge pull request with enough positive reviews.
21972202
settings.protect_approvals_whitelist_enabled = Restrict approvals to whitelisted users or teams

package-lock.json

Lines changed: 163 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"license-checker-webpack-plugin": "0.2.1",
3636
"mermaid": "10.1.0",
3737
"mini-css-extract-plugin": "2.7.5",
38+
"minimatch": "9.0.0",
3839
"monaco-editor": "0.38.0",
3940
"monaco-editor-webpack-plugin": "7.0.1",
4041
"pretty-ms": "8.0.0",

routers/web/repo/pull.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ import (
4545
"code.gitea.io/gitea/services/gitdiff"
4646
pull_service "code.gitea.io/gitea/services/pull"
4747
repo_service "code.gitea.io/gitea/services/repository"
48+
49+
"github.com/gobwas/glob"
4850
)
4951

5052
const (
@@ -575,7 +577,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
575577
if pb != nil && pb.EnableStatusCheck {
576578
ctx.Data["is_context_required"] = func(context string) bool {
577579
for _, c := range pb.StatusCheckContexts {
578-
if c == context {
580+
if gp, err := glob.Compile(c); err == nil && gp.Match(context) {
579581
return true
580582
}
581583
}

0 commit comments

Comments
 (0)