Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special sorting for special characters in globs #109

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

ashleywillard
Copy link
Contributor

@ashleywillard ashleywillard commented Nov 20, 2024

Situation

/frontend/packages/my-thing/src/pages/blah is owned by Foo via a .codeowner file

/frontend/packages/my-thing/src/pages/blah/(bar) is owned by Bar via a .codeowner file

Expected Behavior

The most specific (nested) .codeowner file should take precedence, so /frontend/packages/my-thing/src/pages/blah/(bar)/Sidebar.test.tsx should be owned by Bar.

Actual Behavior

/frontend/packages/my-thing/src/pages/blah/(bar)/Sidebar.test.tsx shows that it is owned by Foo. This is because /frontend/packages/my-thing/src/pages/blah/(bar) is written above /frontend/packages/my-thing/src/pages/blah in the CODEOWNERS file.

This change

This change updates the file sorting such that if two globs match up until a **, then the one without the ** at that location will be prioritized. This ensures that the more specific folder will come last, which means that the file will show the proper owner.

  • TODO: test this on a large repo before merging

Performance seems comparable

@ashleywillard ashleywillard force-pushed the aw/fix-sorting-bug-special-characters branch from 61ddec8 to e7e17b7 Compare November 21, 2024 00:42
@ashleywillard ashleywillard marked this pull request as ready for review November 21, 2024 00:42
@ashleywillard ashleywillard merged commit 8e89d92 into main Nov 21, 2024
5 checks passed
@ashleywillard ashleywillard deleted the aw/fix-sorting-bug-special-characters branch November 21, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants