Skip to content

fix: Make sort order deterministic#162

Merged
BakerNet merged 1 commit into
mainfrom
bugfix/sort-stability
Jun 30, 2026
Merged

fix: Make sort order deterministic#162
BakerNet merged 1 commit into
mainfrom
bugfix/sort-stability

Conversation

@BakerNet

Copy link
Copy Markdown
Collaborator

Related Issue(s)

Closes #154

Summary / Background

Reverse rule ordering is not being respected due to sort.Sort not deterministically retaining reversed ordering. Switch to sort.Stable

@github-actions github-actions Bot requested a review from zbedforrest June 30, 2026 18:31
@github-actions

Copy link
Copy Markdown

Codeowners approval required for this PR:

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces unstable sorting (sort.Sort) with stable sorting (sort.Stable) when ordering codeowner rules. This change ensures that the relative order of rules with the same priority is preserved, maintaining the expected "last declared wins" semantics. A new unit test, TestReadLastMatchWinsSamePriority, along with an in-memory file reader helper, has been added to verify this behavior. I have no feedback to provide as there are no review comments.

@BakerNet BakerNet merged commit fd79353 into main Jun 30, 2026
8 of 10 checks passed
@BakerNet BakerNet deleted the bugfix/sort-stability branch June 30, 2026 18:34
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.

sort.Sort instability breaks last-match-wins for same-priority (globstar) patterns in large .codeowners files

1 participant