Code owners check - match files and directories #197805
Merged
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.
Summary
This PR modifies the code owners check to allow "file" matches for "directory" entries.
Details
Taking the code owner entry
/x-pack/test_serverless/**/test_suites/**/ml/ @elastic/ml-ui
as an example. Note the trailing slash in the path, indicating a directory.Before this PR, if we asked the script for the code owner of
x-pack/test_serverless/functional/test_suites/security/ml
, it would not match, because this requested path doesn't have the trailing slash, thus asking for the fileml
and not the directory. While this is technically correct, it's just too easy to overlook this detail and get a false negative as a result.This PR is removing trailing slashes from the code owners entries when adding them to the lookup table, so they now match both, directory and file requests (and requests for everything within the directory). So going back to the example, all these owner requests would be matched and return
@elastic/ml-ui
as the owner:x-pack/test_serverless/functional/test_suites/security/ml
x-pack/test_serverless/functional/test_suites/security/ml/
x-pack/test_serverless/functional/test_suites/security/ml/index.ts