Skip to content

fix: preserve consumer Git rule precedence - #392

Merged
coisa merged 1 commit into
mainfrom
fix/audit-git-rule-precedence
Oct 21, 2026
Merged

coisa merged 1 commit into
mainfrom
fix/audit-git-rule-precedence

Conversation

@coisa

@coisa coisa commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Closes #378
Closes #385

Changes

  • Keep consumer .gitignore pattern order, repeated patterns and significant whitespace. Prepend canonical defaults once instead of sorting rules and undoing negations.
  • Keep .gitattributes rule order, repetitions, quoted paths and unset/unspecified overrides. Prepend only missing generated defaults; preserve explicit keep-in-export filtering.
  • Preserve anchored versus unanchored glob identities and the literal ignore pattern 0.
  • Update command contracts/docs and replace sort-based expectations with semantic precedence/idempotence regressions.

Verification

  • 29 focused PHPUnit tests / 47 assertions PASS with installed PHPUnit 12.5.38 and PHP 8.4.26. A temporary bootstrap supplies only Safe regex functions; no dependency download or repository vendor alteration. Same tests against original source: 19 failures (RED).
  • Real Git disposable fixtures RED→GREEN: important.log remains not ignored and keep.txt retains export-ignore=unset after synchronization.
  • PHP lint and git diff --check PASS. Independent test-guardian review found/fixed literal 0 and glob anchoring regressions.
  • Full composer dev-tools unavailable locally due missing dependencies; prior dependency download denial respected. Hosted CI must validate full suite.

Documentation / Generated Output

Updated GitIgnore/GitAttributes command docs and merger contracts. No consumer files synchronized.

Changelog

Added .changelog/git-rule-precedence.md (fixed/patch).

Reviewer Notes

Focused correctness fixes, not extraction. Existing history and manual rules retained; no merge, release, or PR #376 changes.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 84dd1632-a153-4adf-a911-4b8fcc05183b
📥 Commits

Reviewing files that changed from the base of the PR and between e81c460 and 793f520.

📒 Files selected for processing: 12
  • .changelog/git-rule-precedence.md
  • docs/commands/gitattributes.rst
  • docs/commands/gitignore.rst
  • src/Console/Command/GitIgnoreCommand.php
  • src/GitAttributes/Merger.php
  • src/GitAttributes/MergerInterface.php
  • src/GitIgnore/GitIgnore.php
  • src/GitIgnore/Merger.php
  • src/GitIgnore/MergerInterface.php
  • tests/GitAttributes/MergerTest.php
  • tests/GitIgnore/GitIgnoreTest.php
  • tests/GitIgnore/MergerTest.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T18:13:32.521665Z 793f520 PR opened
🔒 Security Review ✅ Completed 2026-10-21T18:14:32.187665Z 793f520 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Changelog

✅ Contribution check passed.

Head: 793f520b085b27b6b0f5c36a646a95ce1bcce4be

Base: e81c4600043b8cf38a57f7cbcf274308edbc2582

Contribution: 1 new valid fragment(s). Policy: ordinary.

  • git-rule-precedence.md — fixed, patch

    Preserve consumer rule ordering and overrides when synchronizing `.gitignore` and `.gitattributes`, including repeated patterns, export exceptions, and significant ignore-pattern whitespace. Add generated defaults before existing rules without reordering consumer exceptions.

@github-actions

Copy link
Copy Markdown
Contributor

@coisa
coisa merged commit c9e5b3a into main Oct 21, 2026
52 of 53 checks passed
@coisa
coisa deleted the fix/audit-git-rule-precedence branch October 21, 2026 18:56
@github-project-automation github-project-automation Bot moved this from Backlog to Released in PHP Fast Forward Project Oct 21, 2026
github-actions Bot added a commit that referenced this pull request Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

Preserve gitattributes override precedence during export-ignore merging Preserve gitignore precedence when merging consumer rules

1 participant