For questions regarding the pre-commit framework, not to be confused with git pre-commit hooks generally. Use this tag only when your question involves the framework. The tool pre-commit is a framework for managing and maintaining multi-language pre-commit hooks.
Questions tagged [pre-commit.com]
309 questions
1
vote
1 answer
pre-commit hook yapf returns different results than running yapf in the command line
When running over a file using the command line and yapf, my tags are the following:
-i --verbose --style "google"
When using the same above as args for pre-commit, my pre-commit hook always returns "Pass".
This was tested against the same file…

jtso
- 21
- 3
1
vote
1 answer
Python PDM + pre-commit using pylint: imports cannot be found
Background
I am wrangling some legacy code into shape.
I use PDM to manage dependencies, which places all dependent packages in a __pypackages__ folder directly under the repo root level. PDM also uses the relatively new pyproject.toml package…

Mike Williamson
- 4,915
- 14
- 67
- 104
1
vote
3 answers
pre-commit not able to discover any golang files in nested go module
I have a large repo in the likes of github.com/myusername/myrepo
Now within that repo (for reasons beyond the scope of this question) I have initialised the following go module: github.com/myusername/myrepo/eck-user-mgmt
Here is my…

pkaramol
- 16,451
- 43
- 149
- 324
1
vote
1 answer
sort recommit ignore python file even if asked to scan specifically
I have:
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/timothycrosley/isort
rev: 5.9.2
hooks:
- id: isort
name: Run isort to sort…

Slava
- 325
- 5
- 13
1
vote
1 answer
pre-commit (tool) in jenkins pipelines, nitialize and stop build?
pre-commit is a great tool and id like to incorporate it into jenkins pipelines just to make sure someone didn't try to skip it during committing to the repo.
so my questions are:
what are the best practices to initialize pre-commit? (just…

magna carta
- 17
- 5
1
vote
2 answers
Run a pre-commit hook only if all other hooks are successful
I have a pre-commit setup with several pretty standard repos (for a Python project anyways), and one heavily magical project-specific action.
Something like this:
repos:
- repo: https://github.com/timothycrosley/isort
...
- repo:…

frnhr
- 12,354
- 9
- 63
- 90
1
vote
1 answer
Make pre-commit hooks ignore submodules
I have a git repo with a couple of submodules whose code contents are out of my control. I would like to ignore these submodules in all pre-commit hooks. Is there any way of achieving this short of manually specifying the folders in which these…

RoyalTS
- 9,545
- 12
- 60
- 101
1
vote
2 answers
Setting up gitlint pre-commit local for a repository
I am trying to add a gitlint pre-commit hook in a repository. The .pre-commit-config.yaml file looks lke this:
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
…

Christos Hadjinikolis
- 2,099
- 3
- 20
- 46
1
vote
1 answer
pre-commit.com hook to reject commit if a file contains a specific string
Is there already a pre-commit.com hook to reject commit if a file contains a specific string?
I know how to do this with a git pre-commit hook: https://stackoverflow.com/a/26836281/633961
But I would like to go the pre-commit.com way because this…

guettli
- 25,042
- 81
- 346
- 663
1
vote
1 answer
Any way to get user input from a hook?
I have this ruby code in a hook, but it does not hang to wait for user input as I would like.
puts 'Do you really want to commit on master? [y/N]'
answer = gets.strip
Is there any way to do this?

vmarquet
- 2,384
- 3
- 25
- 39
1
vote
1 answer
Pylint does not ignore migrations
I use Pylint and run it via a pre-commit hook. It doesn't ignore my migrations folders. What should I add to the configuration?
repos:
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.2
hooks:
- id: pylint
name:…

Tatiana
- 576
- 1
- 6
- 23
1
vote
2 answers
Is possible to list the files affected by pre-commit run?
While using pre-commit sometimes I just want to know that filenames are going to be passed to the hook, just to verify that by --from-ref and to-ref are correct. For example, I was running:
pre-commit run flake8 --from-ref $(git merge-base master…

RubenLaguna
- 21,435
- 13
- 113
- 151
1
vote
2 answers
Git pre-commit get all Python files
I'd like to run black to format all the staged .py files on a commit. Unfortunately due to employer network VPN and restrictions I'm unable to use the pre-commit package because it times out when trying to load the repo.
So I decided to write my own…

arjobsen
- 313
- 2
- 12
1
vote
1 answer
Are args in pre-commit-config.yaml overwriting args in pre-commit-hooks.yaml?
We have specified some 'args' in the pre-commit-hooks.yaml file.
If now 'args' are also specified in the pre-commit-config.yaml are these added to the default ones or are these overwriting the default ones?
From the official documentation it is not…

Marko
- 929
- 9
- 27
1
vote
1 answer
pre-commit run yapf --all-files not finding all files?
Running: RH7, Python 3.8.3, pre-commit 2.8.2
I download a repo from github. I make a "bad" change to an existing file, such as not enough empty lines preceding class statement. I run
pre-commit run yapf --all-files
and I get Failed as…

user2133121
- 341
- 1
- 3
- 12