This was generated by AI.
Problem
git-hunk's whole purpose is producing a clean series of focused commits where each commit is independently valid. But nothing enforces that invariant — an agent can stage a partial hunk that leaves the file unparseable (e.g. a selection that drops a closing brace) and only find out later.
Proposal
Add an optional validation command that runs against the staged-tree snapshot and refuses the stage (non-zero exit) on failure:
git-hunk stage 66279ce -l ^115-119 --verify 'python -m py_compile path/to/file.py'
Behavior:
- Materialize the would-be-staged content (the same snapshot
preview would emit), run the --verify command against it, and only commit the stage to the index if the command exits 0.
- On failure, leave the index untouched and report the command's output.
This bakes the "each commit builds" discipline into the tool instead of relying on the agent to remember to check.
Notes
- Depends conceptually on materializing the staged file state (see the
preview issue); could share that machinery.
- Could later be promoted to a configurable default (e.g. a repo-level verify command) but a per-invocation flag is the minimal version.
- One of a set of agent-usability ideas from the same session.
Problem
git-hunk's whole purpose is producing a clean series of focused commits where each commit is independently valid. But nothing enforces that invariant — an agent can stage a partial hunk that leaves the file unparseable (e.g. a selection that drops a closing brace) and only find out later.
Proposal
Add an optional validation command that runs against the staged-tree snapshot and refuses the stage (non-zero exit) on failure:
git-hunk stage 66279ce -l ^115-119 --verify 'python -m py_compile path/to/file.py'Behavior:
previewwould emit), run the--verifycommand against it, and only commit the stage to the index if the command exits 0.This bakes the "each commit builds" discipline into the tool instead of relying on the agent to remember to check.
Notes
previewissue); could share that machinery.