Skip to content

Commit 6a559ad

Browse files
GiteaBotZettat123
andauthored
Fix status_check_contexts matching bug (#28582) (#28589)
Backport #28582 by @Zettat123 Fix #28570 Follow #24633 --- Copied from #28570 (comment) 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 <[email protected]>
1 parent 4dd39eb commit 6a559ad

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

routers/web/repo/pull.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,15 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
637637
if pb != nil && pb.EnableStatusCheck {
638638
ctx.Data["is_context_required"] = func(context string) bool {
639639
for _, c := range pb.StatusCheckContexts {
640-
if gp, err := glob.Compile(c); err == nil && gp.Match(context) {
640+
if c == context {
641+
return true
642+
}
643+
if gp, err := glob.Compile(c); err != nil {
644+
// All newly created status_check_contexts are checked to ensure they are valid glob expressions before being stored in the database.
645+
// But some old status_check_context created before glob was introduced may be invalid glob expressions.
646+
// So log the error here for debugging.
647+
log.Error("compile glob %q: %v", c, err)
648+
} else if gp.Match(context) {
641649
return true
642650
}
643651
}

0 commit comments

Comments
 (0)