Add glob-based support for wildcards in CODEOWNERS file parser (disabled, behind a feature flag)#5030
Merged
konrad-jamrozik merged 2 commits intomainfrom Jan 7, 2023
Merged
Conversation
6ed0cee to
11e3586
Compare
CODEOWNERS file parserCODEOWNERS file parser (disabled, behind a feature flag)
33af552 to
9711f16
Compare
Contributor
Author
|
@weshaggard while the new parser implementation in this PR requires a rewrite, I would like to merge this PR to keep it as a reference, e.g. for the bug I reported here: Is it OK if we merge this? Note the new implementation is not used. I will make a follow-up PR that changes the implementation as we discussed in: UPDATE 1/5/2023 8:12 AM PST: here is the new regex-based parser. The PR for it is based on this PR: |
CODEOWNERS file parser (disabled, behind a feature flag)CODEOWNERS file parser (disabled, behind a feature flag)
weshaggard
reviewed
Jan 6, 2023
weshaggard
reviewed
Jan 6, 2023
weshaggard
approved these changes
Jan 6, 2023
Member
weshaggard
left a comment
There was a problem hiding this comment.
Given the new implementation is currently disabled and you want it for the glob reference I'm good with you merging this and then pulling in your change to switch to regex.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.useNewFindOwnersForClosestMatchImplis by defaultfalse, meaning the code uses the legacy implementation. It is only ever set totruein the added tests.useNewFindOwnersForClosestMatchImplistrue, 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:
FindOwnersForClosestMatchdirectly.Changes to Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj:
Testing done
Next steps
foothe 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:targetPathsare files, always;targetPathis a directory if and only if it ends with/.Microsoft.Extensions.FileSystemGlobbing.Matchermatches glob pattern/*/against file path/a/b, but it shouldn't. dotnet/runtime#80076Reference