Skip to content

Keep Untracked Files Out of the Pre-Commit Snippet's Prose Gate #3370

Closed

Description

@ptr727

The prose-gate entry in catalog/snippets/pre-commit/.pre-commit-config.yaml runs the gate over . with --diff HEAD. pre-commit sets aside unstaged changes to tracked files before running a hook, but it leaves untracked files in place, and the gate's discovery includes them. So an untracked file holding a violation fails a commit that does not include it.

Reproduce in any repository carrying the snippet, with the hook config committed:

printf '# Scratch\n\nThis line has a semicolon; it should trip the gate.\n' > untracked-bad.md
printf '# Clean\n\nA clean line.\n' > staged-clean.md
git add staged-clean.md
pre-commit run

The prose gate fails on untracked-bad.md:3: semicolon, a file the commit does not carry. This was reproduced on ptr727/ESPHome-NonRoot#349, raised there by CodeRabbit.

GOVERNANCE.md "Running the Linters Locally" says the pre-commit scope "is the staged state instead", which is true for tracked files and not for untracked ones.

A likely fix: drop pass_filenames: false from the entry so pre-commit passes the staged paths, and take . out of the entry so those paths are the gate's paths argument, keeping --diff HEAD. Check that the gate still finds a violation on a staged line, and that the GOVERNANCE.md sentence matches what the snippet then does. The Husky.Net snippet and the hub's own .husky/pre-commit judge the working tree by design, so whether an untracked file is in scope there is a separate question.

Done means the repro above passes with the snippet, and a staged violation still fails.

Activity

  1. added a commit that references this issue on Oct 25, 2026
    a245dd1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions