loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix `status_check_contexts` matching bug (#28582)

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

authored by

Zettat123 and committed by
GitHub
907c97aa 19869d1c

+9 -1
+9 -1
routers/web/repo/pull.go
··· 653 653 if pb != nil && pb.EnableStatusCheck { 654 654 ctx.Data["is_context_required"] = func(context string) bool { 655 655 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) { 657 665 return true 658 666 } 659 667 }