Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for auto-commiting hook-made changes #1086

Closed
ArturGajowy opened this issue Jul 20, 2019 · 2 comments
Closed

Option for auto-commiting hook-made changes #1086

ArturGajowy opened this issue Jul 20, 2019 · 2 comments
Labels

Comments

@ArturGajowy
Copy link

The docs say:
The hook must exit nonzero on failure or modify files in the working directory (since 0.6.3).

That is also the observed behavior. In case of a formatter hook though, that means most commits need to be attempted twice: once to re-format them, twice to commit them successfully.

For a sufficiently mature formatter tool, it should be OK to just set sth like auto_commit_changes: true in its hook config. This issue is about adding such an option to pre-commit. WDYT?

@asottile
Copy link
Member

pre-commit will never ever ever modify the staging area, that's not a safe operation and one of the worst anti-features of related tools

See also #879 #806 #999 #747 (please search the issue tracker next time!)

@ArturGajowy
Copy link
Author

Thanks, I found your remark in one of those issues helpful: I can always make my hook do run_formatter && git add -u.

(I did search the tracker)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants