Skip to content

Commit

Permalink
Fix status_check_contexts matching bug (go-gitea#28582)
Browse files Browse the repository at this point in the history
Fix go-gitea#28570
Follow go-gitea#24633

---
Copied from
go-gitea#28570 (comment)

The feature introduced in go-gitea#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
  • Loading branch information
Zettat123 authored and techknowlogick committed Dec 23, 2023
1 parent 896456a commit e1502fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion routers/web/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,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
}
}
Expand Down

0 comments on commit e1502fb

Please sign in to comment.