Protected branches: match the most specific pattern
In a situation where a branch is matched by multiple "protected branch" patterns, I expected the option corresponding to the most specific pattern to be used. However, that is not the case. So for example, let's say these are our protected branches options:
Pattern | Who should be allowed to merge? |
---|---|
something/* |
Maintainers |
something/test/test |
No one |
The natural behavior for me seems to be that no one should be allowed to push to something/test/test
. That is, even though both patterns match something/test/test
, the latter pattern is more specific, and so it seems more natural that the latter pattern be used.
In reality, my testing indicates that in this scenario maintainers are still able to merge. I don't know what rules are used to decide which pattern is used if more than one match. Is it simply that it used the first matching pattern it finds in the list of patterns?
I propose that it should use the most specific matching pattern, as described above.
EDIT: Tested on GitLab Enterprise Edition 11.9.12-ee