'CODEOWNERS syntax: /foobar/** vs /foobar/
Assuming I want to enforce on some directory (e.g. foobar) on my git repository hosted on GitHub a code owner. In the CODEOWNERS file I can specify:
/foobar/** @someuser
But also this would be possible:
/foobar/ @someuser
Is there any difference between these two ways? Is it exactly the same?
Unfortunately, the documentation does not contain any description about this.
Solution 1:[1]
Two consecutive asterisks (**) in patterns matched against full pathname may have special meaning:
A leading
**followed by a slash means match in all directories. For example,**/foomatches file or directoryfooanywhere, the same as patternfoo.**/foo/barmatches file or directorybaranywhere that is directly under directoryfoo.A trailing
/**matches everything inside. For example,abc/**matches all files inside directoryabc, relative to the location of the.gitignorefile, with infinite depth.A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example,
a/**/bmatchesa/b,a/x/b,a/x/y/band so on.Other consecutive asterisks are considered regular asterisks and will match according to the previous rules.
Read more here: https://git-scm.com/docs/gitignore#_pattern_format
As far as I can tell both patterns you describe do the same. Since the CODEOWNERS file works (almost) the same as .gitignore ignoring a folder will ignore all of its sub-folder. So /foobar/** and /foobar/ should be the same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Audwin Oyong |
