Skip to content

Conversation

@treyp
Copy link
Contributor

@treyp treyp commented Mar 12, 2025

📝 Description

In #706, we added support for a parameter to override CODEOWNERS. This worked for simple cases, but because order matters in CODEOWNERS, this did not work well for cases where we wanted to retain broader pattern matches that should take precedence.

For example, imagine a CODEOWNERS file like so:

/foo @owner-foo
/foo/bar @owner-foo-bar
/baz @owner-baz

# Anyone with write access can approve doc changes
*.md

If we wanted to override only the /foo line, we would set: codeowners_overrides:/foo @override.

With the current behavior, where we merely append overrides, this would break ownership of /foo/bar and any *.md files within /foo. Those would now be owned by @override since 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 CODEOWNERS and append any remaining unmatched patterns. This maintains the original CODEOWNERS line order which allows us to override specific lines without overriding the subsequent ones.

@treyp treyp requested a review from a team as a code owner March 12, 2025 18:36
@treyp treyp merged commit bd321be into main Mar 14, 2025
7 checks passed
@treyp treyp deleted the codeowners-overrides-replacements branch March 14, 2025 23:24
@eg-oss-ci
Copy link

🎉 This PR is included in version 1.75.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants