fix(approvals-satisfied): codeowners_overrides should replace existing patterns #707
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.
📝 Description
In #706, we added support for a parameter to override
CODEOWNERS. This worked for simple cases, but because order matters inCODEOWNERS, this did not work well for cases where we wanted to retain broader pattern matches that should take precedence.For example, imagine a
CODEOWNERSfile like so:If we wanted to override only the
/fooline, we would set:codeowners_overrides:/foo @override.With the current behavior, where we merely append overrides, this would break ownership of
/foo/barand any*.mdfiles within/foo. Those would now be owned by@overridesince it was the last line. The only way around this would be to re-define all subsequent rows in the override:codeowners_overrides:/foo @override,/foo/bar @owner-foo-bar,*.md. This gets messy fast.Here, we change the override algorithm to replace any exact pattern matches in
CODEOWNERSand append any remaining unmatched patterns. This maintains the originalCODEOWNERSline order which allows us to override specific lines without overriding the subsequent ones.