Skip to content

Commit 907c97a

Browse files
authored
Fix status_check_contexts matching bug (#28582)
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
1 parent 19869d1 commit 907c97a

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
@@ -653,7 +653,15 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
653653
if pb != nil && pb.EnableStatusCheck {
654654
ctx.Data["is_context_required"] = func(context string) bool {
655655
for _, c := range pb.StatusCheckContexts {
656-
if gp, err := glob.Compile(c); err == nil && gp.Match(context) {
656+
if c == context {
657+
return true
658+
}
659+
if gp, err := glob.Compile(c); err != nil {
660+
// All newly created status_check_contexts are checked to ensure they are valid glob expressions before being stored in the database.
661+
// But some old status_check_context created before glob was introduced may be invalid glob expressions.
662+
// So log the error here for debugging.
663+
log.Error("compile glob %q: %v", c, err)
664+
} else if gp.Match(context) {
657665
return true
658666
}
659667
}

0 commit comments

Comments
 (0)