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
2
votes
1 answer
git COMMIT_EDITMSG not updated after pre-commit hook failed
I am trying to set up a python pre-commit hook that enforces referencing a JIRA id in the commit message. If this JIRA id is not present the commit is rejected/the hook fails. I have a .pre-commit-config.yaml
set up and a dedicted commit-msg.py that…

alaeX
- 21
- 2
2
votes
1 answer
Configure ssh keys for github actions?
I'm using a custom pre-commit hook that's in a private repo.
- repo: git@github.com:username/precommit-hooks.git
rev: v0.0.1
hooks:
- id: check-security
I run it in a github action
- name: Run pre-commit on changed files
…

tgk
- 3,857
- 2
- 27
- 42
2
votes
1 answer
pre-commit config top level exclude doesn't work?
I have the following .pre-commit-config.yaml file. At the first line, I have this top level exclude path to exclude all checks in that folder, but for some reason, the mypy hook still outputs errors from files in that folder. Could someone help me…

WZH
- 354
- 2
- 12
2
votes
1 answer
How to mendate pre-commit hook in local system
In all the repository .pre-commit-config.yaml files are added. This pre-commit hook is responsible to validate commit message and if it is not as per standard then it will generate error.
Now when someone commits into local system at the same time…

Jatin Panchal
- 77
- 8
2
votes
1 answer
Is it possible to add pre-commit configuration file to a non-root folder?
I set up a pre-commit plugin for one of my projects.
Right now, the .pre-commit-config.yaml configuration file is located on the root of the project (as indicated by the official doc https://pre-commit.com/#usage).
Is it possible to move it to a…

Ivo
- 35
- 3
2
votes
1 answer
How to run pre-commit in gitlab CI
I tried setting up a job as follows in my .gitlab-ci.yml file:
precommit:
image: python:3.10.2-slim-bullseye
before_script:
- pip install -r requirements.txt
script:
- pre-commit run --all-files
But the following error is output :
$…

baxx
- 3,956
- 6
- 37
- 75
2
votes
2 answers
getting error when running pre-commit hook for golang repo [named files must be .go files: ./...]
This is the contenct of my .pre-commit-config.yaml file,
repos:
- repo: local
hooks:
- id: static-checks-pramod
name: Static Analysis
description: This hook does static analysis
entry: staticcheck -tests=false ./...
…

pramod
- 117
- 1
- 9
2
votes
1 answer
Error when using the package {precommit}: Executable `...\Rscript` not found
I have installed the package and miniconda as per instructions but I keep on getting this error the error "Executable C:/PROGRA~1/R/R-42~1.0\bin\Rscript not found". I can use Rscript normally in the terminal.
Version information
pre-commit version:…

glhrm
- 51
- 2
2
votes
3 answers
How to solve pre-commit asserttion error on ubuntu 22.04
I am using ubuntu 22.04 and the python version is 3.10.4.
I have installed a Django project with the cookie-cutter. and now I have got an error when I want to commit my changes.
here is the error:
(blog) ➜ blog git:(main) ✗ pre-commit run
[INFO]…

Mahdi Jafari
- 347
- 6
- 22
2
votes
1 answer
Why is does the git end-of-file-fixer keeps adding a unknown character at the end of my file?
I have a .json file on Windows which I tried to commit to my git repo. We have the end-of-file-fixer pre-commit hook activated, to make sure there is always a new line at the end of each file. However, each time I commit my file it adds some unknown…

Roald
- 2,459
- 16
- 43
2
votes
2 answers
How to disable certain pre-commit hooks around specific lines of a file?
Inside gitignore/Global/macOS.gitignore, there are two \r\r as shown in the below screenshot:
I use pre-commit==v4.0.1 with its mixed-line-ending and trailing-whitespace hooks. Both get triggered on this line.
How can I locally disable those hooks…

Intrastellar Explorer
- 3,005
- 9
- 52
- 119
2
votes
1 answer
Jupytext pre-commit config when notebooks are ignored in git
My current hook looks like this:
- repo: local
hooks:
- id: jupytext
name: jupytext
entry: jupytext
language: conda
files: '^notebooks/(.*\.py|.*\.ipynb)$'
args: [--sync, --pipe, black]
The…

Farhood ET
- 1,432
- 15
- 32
2
votes
1 answer
pre-commit x VSCode: env: python3.9: No such file or directory
I use pre-commit to run black flake8 and isort on my code.
I ran pre-commit install and as expected it created .git/hooks/pre-commit which starts like:
#!/usr/bin/env python3.9
# File generated by pre-commit: https://pre-commit.com
# ID:…

ted
- 13,596
- 9
- 65
- 107
2
votes
0 answers
Run pre-commit conventional commit check on squash commit before merge into master only
I want to run the commitizen (python implementation of conventional commit message enforcement) lint check (cz check) within my GitLab CI pipeline but ONLY on the squash commit that precedes a merge into master from a feature branch.
I can't get my…

adamcunnington
- 292
- 1
- 3
- 16
2
votes
0 answers
Can I specify dependencies in mypy.ini?
We run mypy as part of pre-commit. Here is the portion of .pre-commit-config.yaml that refers to mypy
rev: v0.910
# https://github.com/pre-commit/mirrors-mypy/issues/5
hooks:
- id: mypy
name: mypy module1
files:…

jamiet
- 10,501
- 14
- 80
- 159