Add glob-based support for wildcards in CODEOWNERS
file parser (disabled, behind a feature flag)
#5030
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first PR to address:
Changes made
Changes in CodeOwnersFile.cs:
CodeOwnersFile.FindOwnersForClosestMatch
. It now either calls its previous, unchanged, legacy implementation, now located in CodeOwnersFile.FindOwnersForClosestMatchLegacyImpl, or the newly introduced implementation. The decision is made here and is based on newly introduced method feature flag parameter,useNewFindOwnersForClosestMatchImpl
.useNewFindOwnersForClosestMatchImpl
is by defaultfalse
, meaning the code uses the legacy implementation. It is only ever set totrue
in the added tests.useNewFindOwnersForClosestMatchImpl
istrue
, then new implementation is used. That implementation's entry point is the newly-introduced MatchedCodeOwnerEntry ctor.Newly added MatchedCodeOwnerEntry.cs class:
*
and**
during path matching. See the class implementation and comments for details.Newly added Azure.Sdk.Tools.CodeOwnersParser.Tests/CodeOwnersFileTests.cs:
FindOwnersForClosestMatch
directly.Changes to Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj:
Testing done
Next steps
foo
the parser doesn't know if it is a file or a directory. This is a fundamental limitation, because CODEOWNERS entry of formfoo/
should match the path only if it is a directory, but not a file. We could work around this problem in two ways:targetPaths
are files, always;targetPath
is a directory if and only if it ends with/
.Microsoft.Extensions.FileSystemGlobbing.Matcher
matches glob pattern/*/
against file path/a/b
, but it shouldn't. dotnet/runtime#80076Reference