Fix pre-commit hook swiftformat re-staging#308
Merged
RoyalPineapple merged 1 commit intomainfrom Feb 3, 2026
Merged
Conversation
Collaborator
There was a problem hiding this comment.
Did you mean to include this?
|
|
||
| echo "" | ||
| echo " [f] Fix and commit" | ||
| echo " [r] Review - fix and stage, abort to review" |
Collaborator
There was a problem hiding this comment.
It would be nice to have an option that does not stage so that I can look at what the formatter did. This is something I do almost always.
cc50e20 to
e0dde7f
Compare
- Use --lint to detect formatting issues first - Prompt user interactively before making changes [f/r/a] - Fail fast in non-interactive mode (CI) - Use /dev/tty for interactive prompts in git hooks Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
e0dde7f to
65634bd
Compare
meherkasam-square
approved these changes
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The pre-commit hook was formatting Swift files but not re-staging them, leaving the working directory dirty after commits. This fix uses
--lintto detect formatting issues first, then prompts the developer before making changes.Interactive mode: Offers three choices:
[f]Fix and commit - format, stage, and proceed with commit[r]Review - format only (no staging), abort to review changes[a]Abort - no changes madeNon-interactive mode: Fails fast without modifying files.
🤖 Generated with Claude Code