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
0
votes
1 answer
How to combine ggshield and Husky for pre-commit git hook?
I want to combine ggshield(by GitGuardian) and Husky into one pre-commit hook, but the result is that only one of them works.
I tried run pre-commit install in repo and after this run husky install in repo. In that case when i tryed to make commit…

Sergei
- 1
- 1
0
votes
1 answer
How to raise flake8 error when found particular string in whole project.?
When I run flake8 . command I want to raise flake8 error if "print_queries" string is present anywhere in project files checked into VCS (and not excluded).
Here's my flake8 configuration:
[flake8]
exclude = .venv, migrations,…

Abbas Shaikh
- 29
- 6
0
votes
0 answers
Git pre-commit hooks in .yaml file can't push to github
I'm trying to create an R function that automatically creates git commit hooks in the file .pre-commit-config.yaml if it isn't already present in the current directory.
The function is as follows:
create_commit_hook_yaml <- function() {
if…

tsv
- 31
- 6
0
votes
0 answers
How to copy pre-commit?
I want to install pre-commit to a Linux machine that doesnt have access to the Internet so hooks cant be downloaded. I made a copy of .pre-commit-config.yaml on another machine then did pre-commit all hooks were installed. But where all of them are…

GhostKU
- 1,898
- 6
- 23
- 32
0
votes
1 answer
Is it possible to pre-commit run on --from-ref/--to-ref and staged files together
When I invoke:
pre-commit run --from-ref origin/develop --to-ref HEAD: it runs on already committed files
pre-commit run: it runs on staged files
Is there a way to have pre-commit run on both in one command?

Intrastellar Explorer
- 3,005
- 9
- 52
- 119
0
votes
1 answer
How to pass pre-commit args correctly to make the output of the terraform checkov pre-commit hook less verbose?
While I find checkov to be great tool, the default output is way too verbose:
In my above example, it dumps all 78 passed checks as well in the terminal output which makes it hard to find the actual errors which need to be fixed. In fact, the…

Andreas L.
- 3,239
- 5
- 26
- 65
0
votes
1 answer
pre-commit additional_dependencies in a local repository
I'm trying to introduce pre-commit to our project. The project lives in a monorepo, and we would like to have all our checks to live in that same repo as well. We have a flake8 plugin, and I'm trying to configure the flake8 to use that plugin,…

Ibolit
- 9,218
- 7
- 52
- 96
0
votes
1 answer
Is it possible that `pre-commit autoupdate` skips a single linter?
One of the projects I maintain still needs to provide Python 2.7 compatibility.
I use pre-commit with black and black dropped Python 2 support, so I want to stay on e.g. black version 21.9b0, but still I'd like to use pre-commit autoupdate to update…

Jürgen Gmach
- 5,366
- 3
- 20
- 37
0
votes
1 answer
Checks not running on every file (when running -a) even though they are parsed
Summary of the problem
I've setup a repository with the checks I developed, designed to be used exclusively in an another repository.
The problem I've been facing is that when I run pre-commit run -a -v the checks don't go through every file, and…

ExalFabu
- 77
- 7
0
votes
2 answers
Running black only on committed python files
I am just trying to use precommit as a git hook on my python project. What I want to do is to run black only on the committed files. I am also running black through poetry.
At the moment my config looks like:
fail_fast: true
repos:
- repo: local
…

Luca
- 10,458
- 24
- 107
- 234
0
votes
1 answer
Pre-commit Pylint "exit code: 32" upon committing, no issues on `run --all-files`
When I run pre-commit run --all-files all goes well, when I try to commit, pylint throws an error with: Exit code: 32, followed by the list of usage options. The only files changed are .py files:
git status
On branch include-gitlab-arg
Your branch…

a.t.
- 2,002
- 3
- 26
- 66
0
votes
0 answers
pre-commit.com post-checkout hook fails after modifying files
I have a post-checkout hook that substitutes the new branch name into some skeleton files in the "main" branch of the repository. This seems to cause pre-commit to indicate failure when it does what I intend, though this is normally correct…

sappjw
- 373
- 1
- 14
0
votes
1 answer
Making python requests in git pre-commit
So in my pre-commit I want to run python requests to test whether certain urls are valid before committing.
The problem I am having is the requests library is not installed.
Error
- hook id: pre-commit-py
- exit code: 1
Traceback (most recent call…

beautysleep
- 153
- 1
- 9
0
votes
0 answers
pre-commit: Executable python not found when committing a new file
I'm trying to use pre-commit 2.20.0 on Ubuntu 22.04.1 / Python 3.10.6.
I followed the instructions at https://pre-commit.com/#installation and installed pre-commit with pip (22.2.2).
Here's my .pre-commit-config.yaml file:
$ cat…

swiss_knight
- 5,787
- 8
- 50
- 92
0
votes
2 answers
Verify that a commit message contains some string with pre-commit
I would like to ensure if my commit message contains a given string using pre-commit. I tried using a pygrep based hook, but it does not handle the multiline as expected.
For example, my commit message is:
My commit message
Changelog: trial
I want…

RobinM
- 1
- 1