-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds support for [sections] - GitLab style (#204)
## Description - Adds support for sections as in use in GitLab They're not illegal on GitHub (CODEOWNERS with them do check out OK), but I'm not sure they're actually supported yet. ## Motivation and Context - They're 'legal' parts of a CODEOWNERS file both GitHub and on GitLab (and on GitLab they have a documented meaning). Before this PR the virtual-codeowners parser would most of the time reject lines with sections as 'unkown' syntax. - Sections can contain group names that need to be expanded in CODEOWNERS ## How Has This Been Tested? - [x] green ci - [x] Additional unit/ integration tests & expanded _corpus_ ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Documentation only change - [ ] Refactor (non-breaking change which fixes an issue without changing functionality) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) Co-authored-by: Lex McMeadow <[email protected]>
- Loading branch information
Showing
36 changed files
with
741 additions
and
29 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,10 @@ libs/baarden/ [email protected] [email protected] [email protected] tjorus@ | |
|
||
### Any gotcha's? | ||
|
||
It won't check whether the users or teams you entered exist. | ||
- It won't check whether the users or teams you entered exist. | ||
- Only relevant when you're on GitLab: Section heading support is experimental | ||
and when generating labeler.yml default section owners aren't expanded to | ||
section rules. | ||
|
||
### Do I have to run this each time I edit `VIRTUAL-CODEOWNERS.txt`? | ||
|
||
|
@@ -207,6 +210,10 @@ user/team names but doesn't verify their existence in the project. | |
|
||
- valid user/team names start with an `@` or are an e-mail address | ||
- valid rules have a file pattern and at least one user/team name | ||
- valid sections headings comply with the syntax described over at [GitLab](https://docs.gitlab.com/ee/user/project/codeowners/reference.html#sections) | ||
> different from GitLab's syntax the line `[bla @group` is not interpreted | ||
> as a rule, but as an erroneous section heading. This behaviour might change | ||
> to be the same as GitLab's in future releases without a major version bump. | ||
|
||
### I want to specify different locations for the files (e.g. because I'm using GitLab) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/virtual-code-owners/__fixtures__/corpus/empty-teams/015-section-required.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[required-section] | ||
aap/ @some-user @some-other-user |
26 changes: 26 additions & 0 deletions
26
src/virtual-code-owners/__fixtures__/corpus/empty-teams/015-section-required.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
{ line: 1, raw: "[required-section]", type: "section-without-users" }, | ||
{ | ||
filesPattern: "aap/", | ||
inlineComment: "", | ||
line: 2, | ||
raw: "aap/ @some-user @some-other-user", | ||
spaces: " ", | ||
type: "rule", | ||
users: | ||
[ | ||
{ | ||
bareName: "some-user", | ||
raw: "@some-user", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 1, | ||
}, | ||
{ | ||
bareName: "some-other-user", | ||
raw: "@some-other-user", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 2, | ||
}, | ||
], | ||
}, | ||
] |
2 changes: 2 additions & 0 deletions
2
...irtual-code-owners/__fixtures__/corpus/empty-teams/021-section-required-min-approvers.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[required-section][42] | ||
aap/ @some-user @some-other-user |
26 changes: 26 additions & 0 deletions
26
...irtual-code-owners/__fixtures__/corpus/empty-teams/021-section-required-min-approvers.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
{ line: 1, raw: "[required-section][42]", type: "section-without-users" }, | ||
{ | ||
filesPattern: "aap/", | ||
inlineComment: "", | ||
line: 2, | ||
raw: "aap/ @some-user @some-other-user", | ||
spaces: " ", | ||
type: "rule", | ||
users: | ||
[ | ||
{ | ||
bareName: "some-user", | ||
raw: "@some-user", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 1, | ||
}, | ||
{ | ||
bareName: "some-other-user", | ||
raw: "@some-other-user", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 2, | ||
}, | ||
], | ||
}, | ||
] |
5 changes: 5 additions & 0 deletions
5
src/virtual-code-owners/__fixtures__/corpus/empty-teams/022-section-optional.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
^[optional-section] | ||
aap/ @some-user @some-other-user | ||
|
||
^[optional-section-with-default] @koos-koets | ||
noot/ @robbie |
62 changes: 62 additions & 0 deletions
62
src/virtual-code-owners/__fixtures__/corpus/empty-teams/022-section-optional.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[ | ||
{ line: 1, raw: "^[optional-section]", type: "section-without-users" }, | ||
{ | ||
filesPattern: "aap/", | ||
inlineComment: "", | ||
line: 2, | ||
raw: "aap/ @some-user @some-other-user", | ||
spaces: " ", | ||
type: "rule", | ||
users: | ||
[ | ||
{ | ||
bareName: "some-user", | ||
raw: "@some-user", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 1, | ||
}, | ||
{ | ||
bareName: "some-other-user", | ||
raw: "@some-other-user", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 2, | ||
}, | ||
], | ||
}, | ||
{ line: 3, raw: "", type: "empty" }, | ||
{ | ||
inlineComment: "", | ||
line: 4, | ||
optional: true, | ||
raw: "^[optional-section-with-default] @koos-koets", | ||
sectionName: "optional-section-with-default", | ||
spaces: " ", | ||
type: "section-heading", | ||
users: | ||
[ | ||
{ | ||
bareName: "koos-koets", | ||
raw: "@koos-koets", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 1, | ||
}, | ||
], | ||
}, | ||
{ | ||
filesPattern: "noot/", | ||
inlineComment: "", | ||
line: 5, | ||
raw: "noot/ @robbie", | ||
spaces: " ", | ||
type: "rule", | ||
users: | ||
[ | ||
{ | ||
bareName: "robbie", | ||
raw: "@robbie", | ||
type: "other-user-or-team", | ||
userNumberWithinLine: 1, | ||
}, | ||
], | ||
}, | ||
] |
2 changes: 2 additions & 0 deletions
2
...-code-owners/__fixtures__/corpus/empty-teams/023-section-required-with-default-owners.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[required-section] @default-user @default-group | ||
aap/ @some-user @some-other-user |
Oops, something went wrong.