aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-12-22 23:32:22 +0800
committerGitHub <noreply@github.com>2023-12-22 23:32:22 +0800
commit6a559ad6348b95aa1cbb275003699d709af00bfc (patch)
tree5625a901f9fdb279a251b28e170ecf62436e7d90
parent4dd39eb54aed03e2939b4fda6ab683756d878f04 (diff)
downloadgitea-6a559ad6348b95aa1cbb275003699d709af00bfc.tar.gz
gitea-6a559ad6348b95aa1cbb275003699d709af00bfc.zip
Fix `status_check_contexts` matching bug (#28582) (#28589)
Backport #28582 by @Zettat123 Fix #28570 Follow #24633 --- Copied from https://github.com/go-gitea/gitea/issues/28570#issuecomment-1867327999 The feature introduced in #24633 should be compatible with `status_check_contexts`. However, if one or more of `status_check_contexts` is not a legal glob expressions, `glob.Compile` will fail and the contexts cannot match. https://github.com/go-gitea/gitea/blob/21229ed2c8ed00f57100adf9ebc5f4a08da9a66e/routers/web/repo/pull.go#L653-L663 Co-authored-by: Zettat123 <zettat123@gmail.com>
-rw-r--r--routers/web/repo/pull.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index d64e9a57bb..0f1491ae80 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -637,7 +637,15 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
if pb != nil && pb.EnableStatusCheck {
ctx.Data["is_context_required"] = func(context string) bool {
for _, c := range pb.StatusCheckContexts {
- if gp, err := glob.Compile(c); err == nil && gp.Match(context) {
+ if c == context {
+ return true
+ }
+ if gp, err := glob.Compile(c); err != nil {
+ // All newly created status_check_contexts are checked to ensure they are valid glob expressions before being stored in the database.
+ // But some old status_check_context created before glob was introduced may be invalid glob expressions.
+ // So log the error here for debugging.
+ log.Error("compile glob %q: %v", c, err)
+ } else if gp.Match(context) {
return true
}
}