Questions tagged [pre-commit-hook]
In the context of Software Configuration Management (SCM), a pre-commit hook is a command run just before a commit is performed.
642
questions
0
votes
0
answers
27
views
pre-commit hooks do not find python [duplicate]
Using a Windows 10 machine and having pre-commit hooks locally, when I try to create a commit and they are triggered I see that they fail with the error:
Python was not found; run without arguments to ...
-1
votes
0
answers
10
views
Get git hook error in git kraken with pre-commit hook [closed]
Getting path error in git kraken pre-commit hook
[1]: https://i.stack.imgur.com/mA0Ax.png
-1
votes
0
answers
64
views
terraform_docs pre-commit hook, specify folder path
My directory structure is the following
└── tf-dev
├── README.md
└── terraform/
└── .pre-commit-config.yaml
My Terraform files are in terraform.
I cannot make terraform-docs working with ...
-1
votes
0
answers
12
views
Can you check that functions/classes have been added to sphinx docs pages in CI?
When adding new features its sometimes quite easy to forget to add new functions and classes into the API documentation.
As far as I know (at least in python sphinx) You need to explicitly add the new ...
0
votes
1
answer
36
views
How to get remote name in pre-commit hook on push
How to get the name of the remote when doing push or pre-push in pre-commit.com
0
votes
0
answers
27
views
husky - pre-commit hook exited with code 127 (error) - npm command not found [duplicate]
Why does husky not find npm? I tried husky in another project and it worked fine. The only difference to that other configuration is that i use npm and not pnpm now. Why does it fail?
prepare script ...
-1
votes
0
answers
44
views
What is the best way to add TypeScript checking as pre-commit hook?
I'm using lint-staged for handling pre-commit hooks.
const path = require("path");
const buildEslintCommand = (filenames) =>
`next lint --fix --file ${filenames
.map((f) => path....
0
votes
2
answers
67
views
Is it possible to stop the editor from popping up once git prepare-commit-msg hook is called?
I am writing a prepare-commit-msg hook, which interactively prompts the user about some data and creates a commit message in a predefined format. In almost all cases, there is no need for the user to ...
-1
votes
1
answer
51
views
Pre-commit shows different result when running directly in command line vs running from make
I have a Makefile that contains this:
SOURCE_DIR=./some_codebase/**/*
check-mypy:
pre-commit run mypy --files $(SOURCE_DIR)
When I trigger make check-mypy, the result shows up as Passed (which ...
0
votes
0
answers
26
views
How to implement pre-receive git hook for a hosted git services
I'm Looking for a way to create a pre-receive hook for git repo hosted on gitlab/github.
Hosted git solutions do not support these server-side hooks and I'm looking for a way to mitigate it under ...
1
vote
1
answer
102
views
Running pre commits, excluding a directory for multiples hooks
I'm trying to configure pre-commits to avoid the directory app/test/
I can exclude it directly on the hook, for exemple avec mypy :
In cmd line :mypy . --exclude ^app/test/$
In the pre-commit.yaml ...
2
votes
1
answer
91
views
pre-commit not picking files for pip-tools
I've the following repo structure:
libs/
- l1/
- pyproject.toml
- l2/
- pyproject.toml
batch/
- b1/
- pyproject.toml
- b2/
- pyproject.toml
pipelines/
- p1/
- pyproject.toml
- p2/
- pyproject....
0
votes
1
answer
58
views
pre commit script for code review using spotbug
I am trying to write a script for a code review using a pre-commit hook. I am looking for a script that will run on every commit and perform the code review using SpotBugs or a similar tool. I have ...
0
votes
0
answers
43
views
husky pre-commit hook not triggered
I have set up husky pre-commit hook. I decided to follow version 4.3.8 as I have previously used it.
I have added this to my package.json"
"lint-staged": { "*": "...
0
votes
0
answers
142
views
How to get new-style ESLint config working with pre-commit?
I've got a project with a .pre-commit-config.yaml that features, among other things, the official ESLint hook. It works perfectly when using the old-style .eslintrc.json config, but replacing it with ...
0
votes
1
answer
121
views
Using pre-commit tool, is there a way to pass filenames one by one to the `entry` program?
Using pre-commit, I'm trying to invoke PSScriptAnalyzer tool as a static checker for PowerShell scripts.
Since there is no pre-commit language for PowerShell and I don't want to add an additional ...
0
votes
1
answer
36
views
Break a git commit apart during pre-commit
I am interfacing with a system that processes builds based upon a comment. Each file requires it's own comment, and I can capture the comment from a third party system.
The pre-commit script seems ...
0
votes
1
answer
109
views
Getting the error "fatal: cannot run .git/hooks/pre-commit: No such file or directory" when trying to execute git commit. The pre-commit file is there
My Situation
I've got a pre-commit hook installed within the .git/hooks directory of my project. However, whenever I try to perform a git commit -m "whatever" for a commit, I just get an ...
-1
votes
1
answer
117
views
Inline bash script in pre commit hook
- id: check-modified-files
name: Check for Modified Unstaged Files
entry: bash
language: system
args:
- -c
- |
if [ $(git diff Resources/...
0
votes
0
answers
64
views
commit-msg hook gives "[[: not found" error
My .git/hooks/commit-msg file looks like
#!/bin/sh
COMMIT_MSG_FILE=$1
comm_msg=$(head -l $COMMIT_MSG_FILE)
if [[ $comm_msg =~ ^TASKID-[\d]+ ]]; then
exit 0
else
echo "Commit message must ...
2
votes
0
answers
454
views
Pre-commit mypy dep resolution not equivalent to running mypy natively
Crossposting this to SO since the issue was closed on the repo by the maintainer on Github https://github.com/pre-commit/pre-commit/issues/2951 without resolution and I'm unable to find out what the ...
-1
votes
1
answer
311
views
Pre-commit hook skips files in directory
I'm trying to implement SQLFLUFF linter on a certain directory (models/market) on a repo. I'm using this command pre-commit run --files models/market/
what I see is that it is skipping .sql files ...
0
votes
0
answers
60
views
Does Playwright have equivalent functionality to "--findRelatedTests" in Jest?
I will be running Playwright VR Tests with a pre-commit hook. My test files are co-located with each compoinent. Instead of running all tests each time, I am looking for a feature (or other solution) ...
-1
votes
1
answer
155
views
pre commit hook files skipped
repos:
- repo: https://github.com/terraform-docs/terraform-docs
rev: "v0.16.0"
hooks:
- id: terraform-docs-go
args: ["markdown", "table", "--...
0
votes
1
answer
178
views
How can I run pre commit hooks again after running "git commit --no-verify"?
Let's say I committed some code to the remote repository but skipped the commit hooks with git commit --no-verify since it was a WIP branch. But now I want to run those pre commit hooks on the same ...
-1
votes
1
answer
235
views
Pre-Commit hooks on MacOs require superuser to work
I am working on a python project with a MacOs laptop, I just installed pre-commit with pip install pre-commit and then pre-commit install, and when I try to commit or execute pre-commit run --all-...
1
vote
1
answer
1k
views
How can I resolve this error regarding dbt templater? Templater cannot be set in a .sqlfluff file in a subdirectory of the current working directory
I am trying to use dbt templater with pre-commit hooks, but I am constantly receiving this error message:
Attempt to set templater to dbt failed. Using jinja templater. Templater cannot be set in a ....
0
votes
0
answers
267
views
Python mypy-mirror in precommit, how to find a list of additional dependencies
I have .pre-commit set with the following config:
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
additional_dependencies: [types-...
-1
votes
1
answer
66
views
running precommit hooks with codeql/GHAS sast scans?
I'm just getting started with CodeQL and we have a requirement from our devs to CodeQL sast scans as precommit hooks. I could not find any docs on how to set up CodeQL to make it run on my machine.
...
0
votes
1
answer
191
views
Why isn't My Git pre-commit Hook Working with Spring Boot and Gradle?
How to implement Git pre-commit/pre-push hook in Spring boot for gradle project?
I have implemented at my project but its not working.
Step 1: Created a pre-hook script, let's create pre-commit file ...
-1
votes
1
answer
187
views
Pnpm for pre-commit custom hook
I work on a python/svelte full-stack app where we use pre-commit. I've installed stylelint to frontend web dir and configured a custom hook for it :
- id: stylelint
name: stylelint
...
0
votes
0
answers
221
views
Precommit Hook is running prettier command on the folder which is not mentioned in the prettier command
I have a command in package.json:
"prettier:fix": "npx prettier backend --write"
Now I have setup eslint-staged as:
"lint-staged": {
"**/*.{js,json}": [
...
0
votes
0
answers
35
views
How can I give a file as an input to the precommit hook in angular
There has been some incidence where I have committed some file with 'fdescribe' and 'fit' and the build failed. A lot of time gets wasted on this.
I want that I should not even be allowed to commit ...
1
vote
1
answer
63
views
Bash get pid of cygwin terminal
I use the git pre-commit hook to run an autoformat-script format-src.sh
that is based on clang-format. Some developers use github-desktop where it is not
easy possible to install the clang-format ...
-1
votes
2
answers
329
views
Pre-commit hooks always fails with index.lock already exists
When running the hooks in the pre-commit-config.yaml the hook fix-encoding-pragma e debug-statements fails (remove the # -*- coding: utf-8 -*- for example, but fails) and then i can't proceed to the ...
0
votes
0
answers
84
views
Installing environment for https://github.com/igorshubovych/markdownlint-cli fails with AttributeError: 'bytes' object has no attribute 'tell' #328
I am using
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.2
hooks:
- id: markdownlint
Sometimes, pre-commit fails with the following error.
[INFO] Installing ...
0
votes
1
answer
631
views
pre-commit: Missing required key: name will local hook
I'm trying to set up a custom repo: local hook with pre-commit and running into an error message that I don't understand
My steps:
From C:\Python\monorepo\project1\project1_app\ (in PyCharm terminal):...
0
votes
0
answers
62
views
precommit broke after canceling out of a commit
I have a python app and angular app in my lerna monorepo. I have husky precommit hook (legacy) set up for the angular app as well as a python precommit hook. The precommit hook runs my command npm run ...
2
votes
2
answers
476
views
Select all the files with a spefic extension Github actions workflow
Hi I am trying to run a pre-commit hook on all the files with .sql extension. I was wondering how can I do that. All those files with .sql are in the models/ directory, but I have sub-directories ...
0
votes
1
answer
2k
views
black and flake8 hooks conflicts
Black fail and reformat the following
foo1 = foo2[len(foo3):]
to
foo1 = foo2[len(foo3) :]
But Flake8 fails with
foo1 = foo2[len(foo3) :]
and wants
foo1 = foo2[len(foo3):]
Unless I am mistaken, in ...
0
votes
0
answers
162
views
yamlfix not picking up updates to pyproject.toml
So the yamlfix docs say you can configure through pyproject.toml
https://lyz-code.github.io/yamlfix/#auto-configure-through-pyprojecttoml
But I can't find a way to make yamlfix, and pre-commit that is ...
-1
votes
1
answer
255
views
Interrogate pre-commit, print results even on pass
I'm using the interrogate pre-commit on my repo. There are a number of legacy files that don't contain doc-strings and currently the pre-commit fails when committing changes on these. Ideally, I'd ...
0
votes
2
answers
123
views
How to make Git file size checking faster?
I have a bash script that checks whether the files to be committed fit a size limitation. However, when there are a large number of files, the script can take a long time to complete, even if there ...
0
votes
1
answer
121
views
Trying to make a pre-commit hook that checks if files in index are formatted correctly
I've been trying to make a pre-commit hook that checks if files in the index are formatted correctly. I've tried so many things already but I just can't get the grep to work correctly. This is my code ...
0
votes
1
answer
169
views
Github Desktop not honouring pylint installed in a .venv
I have a python project running in a virtual environment (created by poetry).
pylint is installed only in the virtual environment, not in the base.
pylint works well in the venv from command line, via ...
0
votes
0
answers
107
views
Python and pylint: conflicting errors
My rssita.py python code has the following lines:
from feeds import RSS_FEEDS
from termcolors import PC
and this is the corresponding directory tree:
(rssita-py3.10) (base) bob@Roberts-Mac-mini ...
0
votes
0
answers
227
views
What is the difference between creating tox environment for linting and using pre-commit hooks
I am learning CI/CD for Python packages and have worked through the text and examples in Dane Hillards's new Book Publishing Python Packages. I know there are a lot of different tools and approaches, ...
0
votes
2
answers
2k
views
Pre-commit install-hooks does not work (SSLError)
I use conda Python environments. Whenever I try to run pre-commit install-hooks, I get the error
Could not fetch URL https://pypi.org/simple/ruamel-yaml/: There was a problem confirming the ssl ...
17
votes
2
answers
7k
views
pre-commit fails to install isort 5.10.1 with error "RuntimeError: The Poetry configuration is invalid" [duplicate]
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: ...
-1
votes
1
answer
1k
views
How do I exclude multiple folders and/or file-patterns from pre-commit analysis?
I have my python project. I'm trying to setup pre-commit checks using pre-commit. I want to exclude some folders and some files (by pattern) from the analysis. The `exclude tag in config file only ...