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

stages: [commit] hooks will run with pre-commit run otherhookid #772

Closed
asottile opened this issue Jun 30, 2018 · 0 comments · Fixed by #803
Closed

stages: [commit] hooks will run with pre-commit run otherhookid #772

asottile opened this issue Jun 30, 2018 · 0 comments · Fixed by #803

Comments

@asottile
Copy link
Member

minor logic bug, good new-contributor ticket

Easy to reproduce on pre-commit itself:

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a146bd2..7bb382d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -3,6 +3,7 @@ repos:
     rev: v1.2.3
     hooks:
     -   id: trailing-whitespace
+        stages: [commit]
     -   id: end-of-file-fixer
     -   id: autopep8-wrapper
     -   id: check-docstring-first
$ pre-commit run end-of-file-fixer --all-files
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed

(it should have only run end-of-file-fixer but also run trailing-whitespace due to a logic error).

mblayman added a commit to mblayman/pre-commit that referenced this issue Jul 20, 2018
This branches fixes the run logic so that when
`pre-commit run some_hook -a` runs when the config contains
`stages: ['commit']` for some other hook, only the hook specified as an
argument will run.

Fixes pre-commit#772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant