Skip to content

test: match .gitattributes rules as whole lines in the drift guard - #562

Merged
cevheri merged 1 commit into
libredb:mainfrom
HasselNot7:test/anchor-gitattributes-guard
Sep 5, 2026
Merged

test: match .gitattributes rules as whole lines in the drift guard#562
cevheri merged 1 commit into
libredb:mainfrom
HasselNot7:test/anchor-gitattributes-guard

Conversation

@HasselNot7

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

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 two toContain assertions with a whole-line match (^rule$ with the m flag; literals are regex-escaped). The same anchoring is applied to the four #114 patterns.

Testing

  • I have tested this locally

  • I have added/updated tests

  • bun test tests/unit/gitattributes.test.ts on this branch: 2 pass / 0 fail.

  • Confirmed the guard now fails when the rule is commented out as # * text=auto eol=lf (the old toContain passed in that case), then restored the file.

  • eslint clean on the changed file.

Screenshots (if applicable)

n/a (test-only change).

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have added tests that prove the guard is effective
  • Test-only change; no runtime code is touched

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).

@cevheri cevheri added good first issue Good for newcomers hacktoberfest-accepted Merged Hacktoberfest PR; counts for the participant labels Sep 5, 2026
@cevheri
cevheri merged commit c476239 into libredb:main Sep 5, 2026
22 checks passed
@cevheri

cevheri commented Sep 5, 2026

Copy link
Copy Markdown
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.

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

Labels

good first issue Good for newcomers hacktoberfest-accepted Merged Hacktoberfest PR; counts for the participant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants