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

Question: Is it possible to add --show-diff-on-failure to git hook runs and not just CLI runs? #1712

Closed
xdesai opened this issue Nov 24, 2020 · 2 comments
Labels

Comments

@xdesai
Copy link

xdesai commented Nov 24, 2020

Sorry if a github issue is not the correct place for this question. We can close it out and take this somewhere else if need be.

From https://pre-commit.com/#pre-commit-run I learned about --show-diff-on-failure and it's something that I have been wanting in precommit since we started using it. It seems clear to me how to implement this when running precommit on the command line. But we use a .pre-commit-config.yaml and git hooks to run pre-commit and I couldn't find a way to turn this setting on.
Is it possible and I'm just missing something? Or is this technically a feature request?

@xdesai xdesai changed the title Question: Question: Is it possible to add --show-diff-on-failure to git hook runs and not just CLI runs? Nov 24, 2020
@asottile
Copy link
Member

the option is only intended for usage in CI, not for use in git hooks

that said, you could do this as a hook:

-   repo: local
    hooks:
    -   id: git-diff
        name: git diff
        entry: git diff --exit-code
        language: system
        pass_filenames: false
        always_run: true

@xdesai
Copy link
Author

xdesai commented Nov 24, 2020

Fair enough!
I personally just like to see what black and other formatters change when it auto-formats my commits. I'll definitely give this hook a try though.
Thanks for the quick response. Appreciate it!

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