Skip to content

fix hooks firing during staged_files_only - #1422

Merged
asottile merged 1 commit into
pre-commit:masterfrom
domodwyer:bugfix/stash-with-post-checkout-hook
May 2, 2020
Merged

fix hooks firing during staged_files_only#1422
asottile merged 1 commit into
pre-commit:masterfrom
domodwyer:bugfix/stash-with-post-checkout-hook

Conversation

@domodwyer

@domodwyer domodwyer commented Apr 29, 2020

Copy link
Copy Markdown
Contributor

pass through an environment variable to prevent hooks running

Fixes #1418.

@domodwyer

Copy link
Copy Markdown
Contributor Author

Running git checkout-index --all --force is not equivalent, so changed to using the env var to skip hooks triggered by the git checkout call.

Comment thread pre_commit/commands/run.py Outdated
Comment thread pre_commit/staged_files_only.py Outdated
@domodwyer

Copy link
Copy Markdown
Contributor Author

I've pushed the changes - I started adding a test case for this, but it's a bit beyond my python skill level I'm afraid.

Comment thread pre_commit/commands/run.py Outdated
Comment thread pre_commit/staged_files_only.py Outdated
@asottile

Copy link
Copy Markdown
Member

needs a test as well

@domodwyer

Copy link
Copy Markdown
Contributor Author

needs a test as well

As I said, I'm trying to help without really knowing python - the tests are particularly hard to pick apart.

@asottile

Copy link
Copy Markdown
Member

oh ok, I can help wiht the test

@asottile asottile changed the title staged-files: use git checkout-index fix pre-commit firing during staged_files_only May 2, 2020
@asottile asottile changed the title fix pre-commit firing during staged_files_only fix hooks firing during staged_files_only May 2, 2020

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a test! thanks again!

@asottile
asottile merged commit df01824 into pre-commit:master May 2, 2020
@domodwyer

Copy link
Copy Markdown
Contributor Author

Great cat, thanks for your help!

@asottile

Copy link
Copy Markdown
Member

thanks again for the fix and report, this has been released as part of v2.4.0 🎉

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

post-checkout hook prevents pre-commit hooks from working with unstaged files

2 participants