test: match .gitattributes rules as whole lines in the drift guard - #562
Merged
Merged
Conversation
cevheri
approved these changes
Sep 5, 2026
Member
|
Merged, thank you. Checked it the way you described: with the rule commented out the new guard fails while the old toContain version still passed, so this closed a real gap. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Follow-up to #555, implementing @cevheri's review suggestion. The drift guard used
toContain(...), which also matches a commented-out rule (# * text=auto eol=lf), so it wasn't really guarding the line. This anchors each rule to a whole line with a multiline regex, so a commented-out or altered rule fails the check.Type of Change
Related Issue
Follow-up to #555 (suggestion: #555 (comment)). Does not close an issue on its own.
Changes Made
tests/unit/gitattributes.test.ts: replace the twotoContainassertions with a whole-line match (^rule$with themflag; literals are regex-escaped). The same anchoring is applied to the four#114patterns.Testing
I have tested this locally
I have added/updated tests
bun test tests/unit/gitattributes.test.tson this branch: 2 pass / 0 fail.Confirmed the guard now fails when the rule is commented out as
# * text=auto eol=lf(the oldtoContainpassed in that case), then restored the file.eslintclean on the changed file.Screenshots (if applicable)
n/a (test-only change).
Checklist
Additional Notes
Implements the maintainer's own optional follow-up from #555. AI-assisted (agent drafted the change; verified manually with the comment-out check above).