branch protection status check pattern
gzzi opened this issue · 3 comments
Description
Hi,
I have a branch protection status check pattern issue. My pattern use a glob and is **/*@(code_style|affected). On the setting page, I see that my CI is marked as match (see first screenshot). But on pull request view same CI passed but a extra line is added with the pattern and written as required (see second screenshot).
Gitea Version
1.22.6
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
Git Version
No response
Operating System
No response
How are you running Gitea?
unsure but I think it's docker image
Database
None
Gitea uses two different libs to test glob patterns.
On the branch protection setting page (the first screenshot), we test the pattern with js code.
gitea/web_src/js/features/repo-settings.ts
Lines 100 to 117 in 40765b5
On the pull request page (the second screenshot), we test the pattern with go code.
gitea/routers/web/repo/pull.go
Lines 481 to 496 in 40765b5
So I think the cause of this bug may be related to the go glob library we are using (gobwas/glob).
As a workaround, maybe you could use two patterns
**/*code_style
**/*affected
go glob library doesn't support extended syntax (gobwas/glob#3) and @(...) is part of extended one according to bash man:
If the extglob shell option is enabled using the shopt builtin, the shell recognizes several extended pattern matching operators.
[...]
@(pattern-list)
Matches one of the given patterns.
There are two options for solving this as far as I can see:
- Fix go library to support extended pattern (or replace it with one that has)
- Disable extended syntax for minimatch
Second one is obviously easier and I can make a PR for this.
By looking at go glob I found out that it was in fact possible without using extended pattern. The syntax is:
**/*{affected,code_style}

