Different behavior in status check pattern matching with ** #14952

Closed
opened 2025-11-02 11:26:38 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @LordBaryhobal on GitHub (Sep 12, 2025).

Description

Context

When configuring banch protection, you can enable status checks. You are prompted to enter some patterns to match required status checks. The patterns are first matched against recent status checks using the minimatch JS package. But when they are enforced, on the backend, they are matched using the gobwas/glob Go package. This leads to some differences in behaviors (as seen in #33121

Issue

The main issue I am facing right now is the difference in the meaning of "**". It seems like the Go package implements it as a "match any character, any number of times", while the minimatch implements it in a more path-related way, matching "multiple folder names".

Here is a minimal working example in Go, which correctly matches the status check context.

package main

import (
    "fmt"
    "github.com/gobwas/glob"
)

func main() {
    pattern, _ := glob.Compile("Check**")
    if pattern.Match("Check / check (pull_request)") {
        fmt.Println("Matches")
    } else {
        fmt.Println("Doesn't match")
    }
    // -> Matches
}

And here is the same example using the minimatch JS package, which doesn't work because of the "/" in the status check context:

const {minimatch} = require("minimatch")
const matches = minimatch("Check / check (pull_request)", "Check**", {noext: true})
if (matches) {
    console.log("Matches")
} else {
    console.log("Doesn't match")
}
// -> Doesn't match

Possible solution

I don't know how to make minimatch work the same as gobwas/glob or if it is even possible. However, if the patterns were to be RegExps, I think it would be easier to have matching libraries both in Go and JS. Is there a particular reason to use globs instead of regular expressions ?

Demo repo: https://demo.gitea.com/LordBaryhobal/test-status-check

Gitea Version

1.24.4

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Branch protection rule, status check is not marked as "Matched"

Image

Pull request, check is marked as required

Image

Git Version

No response

Operating System

No response

How are you running Gitea?

Docker image

Database

None

Originally created by @LordBaryhobal on GitHub (Sep 12, 2025). ### Description ## Context When configuring banch protection, you can enable status checks. You are prompted to enter some patterns to match required status checks. The patterns are first matched against recent status checks using the [`minimatch`](https://www.npmjs.com/package/minimatch) JS package. But when they are enforced, on the backend, they are matched using the [`gobwas/glob`](https://github.com/gobwas/glob) Go package. This leads to some differences in behaviors (as seen in [#33121](https://github.com/go-gitea/gitea/issues/33121) ## Issue The main issue I am facing right now is the difference in the meaning of "**". It seems like the Go package implements it as a "match _any_ character, any number of times", while the `minimatch` implements it in a more path-related way, matching "multiple folder names". Here is a minimal working example in Go, which correctly matches the status check context. ```go package main import ( "fmt" "github.com/gobwas/glob" ) func main() { pattern, _ := glob.Compile("Check**") if pattern.Match("Check / check (pull_request)") { fmt.Println("Matches") } else { fmt.Println("Doesn't match") } // -> Matches } ``` And here is the same example using the `minimatch` JS package, which doesn't work because of the "/" in the status check context: ```js const {minimatch} = require("minimatch") const matches = minimatch("Check / check (pull_request)", "Check**", {noext: true}) if (matches) { console.log("Matches") } else { console.log("Doesn't match") } // -> Doesn't match ``` ## Possible solution I don't know how to make `minimatch` work the same as `gobwas/glob` or if it is even possible. However, if the patterns were to be RegExps, I think it would be easier to have matching libraries both in Go and JS. Is there a particular reason to use globs instead of regular expressions ? Demo repo: https://demo.gitea.com/LordBaryhobal/test-status-check ### Gitea Version 1.24.4 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots ### Branch protection rule, status check is not marked as "Matched" <img width="1016" height="344" alt="Image" src="https://github.com/user-attachments/assets/60aacc56-c894-4eb2-aa3e-d8dd44e79d4b" /> ### Pull request, check is marked as required <img width="984" height="285" alt="Image" src="https://github.com/user-attachments/assets/0abad2b5-2b0c-46c8-8208-6814822836e8" /> ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Docker image ### Database None
GiteaMirror added the type/bug label 2025-11-02 11:26:38 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Sep 12, 2025):

-> Fix different behavior in status check pattern matching with double stars #35474

@wxiaoguang commented on GitHub (Sep 12, 2025): -> Fix different behavior in status check pattern matching with double stars #35474
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14952