Skip to content

Commit

Permalink
document autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
iafisher committed Dec 1, 2024
1 parent 25d79cc commit 4843bc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ cmd = ["iprecommit-no-forbidden-strings", "--commits"]
- `name` and `cmd` are the only supported keys for `pre_push` checks.
- `cmd` is passed a list of Git revisions to be pushed to the remote repository.

### Autofix
If the top-level `autofix` option is set to `true` in the TOML file, then when a fixable check fails, `iprecommit run` will automatically invoke `iprecommit fix`, and then re-run `iprecommit run` after. This is useful if you have, e.g., auto-formatting checks that can fix themselves without human intervention.

## Custom commands
These commands are designed to be used with `iprecommit`, but they can also be used independently.

Expand Down
4 changes: 4 additions & 0 deletions iprecommit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ def replace_file(path: Path, new_contents: str) -> None:
# This file configures Git hooks for the project.
# Documentation: https://github.com/iafisher/iprecommit
# Set 'autofix' to 'true' to automatically run 'iprecommit fix' if a fixable
# check fails.
autofix = false
[[pre_commit]]
name = "NoForbiddenStrings"
cmd = ["iprecommit-no-forbidden-strings", "--paths"]
Expand Down

0 comments on commit 4843bc9

Please sign in to comment.