Skip to content

Diff a Merge Commit Against MERGE_HEAD in the pre-commit Framework Snippet's Prose Gate #4131

Closed

Description

@ptr727

Finding

catalog/snippets/pre-commit/.pre-commit-config.yaml runs the prose gate with --diff HEAD. During a merge, the pre-commit framework passes the gate the conflicted files and the files the resolution changes. A comment line the merged-in parent brought into such a file then reads as added against HEAD, and comment-added refuses the merge commit.

This is the class #4104 fixes in catalog/snippets/husky/pre-commit, which now diffs a merge commit against MERGE_HEAD, as the hub's own .husky/pre-commit already did. The framework config could not take the same fix in that change. Its entry is a command line rather than a shell script, so choosing the base there needs a shell wrapper whose behavior under Git for Windows was not verified.

Constructed case

  1. On develop, commit conflict.py holding VALUE = "base" below a few blank lines.
  2. Branch feature, and change the value to "feature".
  3. On develop, change it to "develop" and add a comment line at the top of the file.
  4. On feature, with the config's prose-gate hook installed, run git merge develop. It conflicts on the value.
  5. Resolve the value, keep develop's comment line, stage, and run git commit --no-edit.

The hook prints Checking merge-conflict files only. and refuses the commit with conflict.py:1: comment-added, although the merge adds no comment of its own. Run against the hub at fa06887f.

Expected

On a merge commit the gate diffs against MERGE_HEAD, as both Husky.Net hooks now do. One shape that also serves the Husky.Net hooks is for prose_lint.py to choose that base itself, for example a --diff value meaning HEAD, or MERGE_HEAD while a merge is in progress. The two hook files would then drop their duplicated base choice. That consolidation was raised by the local review of the pull request fixing #4104.

Found by

The local strict review of the pull request fixing #4122, #4104 and #4121, confirmed by the constructed case above.

🤖 Generated with Claude Code

Activity

  1. added
    pre-existing
    on Nov 13, 2026
  2. ptr727 commented on Nov 13, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim, round 2 (2026-11-13), away run, scope develop. Branch burndown/hook-chain-gate, group: #4131, #4135, #4123, #4108. Tier: frontier (carried hook snippets and helper, the prose gate, entangled across one hook chain).

    Predicted files:

    • .github/actions/prose-gate/prose_lint.py
    • .github/actions/prose-gate/prose-gate.json
    • scripts/prose_lint.py
    • tests/test_prose_lint.py
    • catalog/snippets/pre-commit/.pre-commit-config.yaml
    • catalog/snippets/pre-commit/README.md
    • catalog/snippets/husky/pre-commit
    • catalog/snippets/husky/README.md
    • .husky/pre-commit
    • .husky/pre-push
    • catalog/snippets/hub_fetch_run.py
    • tests/test_hub_fetch_run.py
    • tests/test_pre_commit_hook.py
    • scripts/README.md
    • GOVERNANCE.md ("Running the Linters Locally (Known-Working Invocations)", the hook's diff-base sentence)
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

    pre-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions