Add support for automatic re-commit after formatter hooks (Black/Ruff)
Currently, when using formatter hooks such as Black or Ruff, the commit process is interrupted:
- The formatter modifies files.
- The commit fails due to file changes.
- The user must manually stage and re-commit.
This behavior is understandable, but it can disrupt workflow efficiency, especially for purely formatting-related hooks.
Proposal:
Please consider introducing an option (for example, --auto-fix-continue) or a configuration flag that automatically re-stages the modified files and continues the commit process after successful formatting.
Rationale:
- Helps reduce repetitive manual steps when formatters are used as part of the hook chain.
- Maintains a seamless and efficient commit flow.
- Provides a smoother experience for new or less experienced developers, who may otherwise be confused by commit interruptions after automatic formatting.
- Keeps behavior configurable for users who prefer strict pre-commit validation.
Example Workflow:
# Current behavior
git commit -m "refactor utils"
# → Black runs, modifies files
# → Commit fails
# → User must git add . && git commit again
# Proposed behavior
git commit -m "refactor utils"
# → Black runs, modifies files
# → Prek automatically re-stages changes and continues the commit
# → Commit succeeds without interruptionAdditional Suggestion: It would be great if this could be implemented as a per-hook configuration option, allowing only specific tools (e.g., formatters like Black or Ruff) to auto-fix and continue, while other hooks (e.g., linters, tests) retain the standard failure behavior.
Source: j178/prek