Questions tagged [pre-commit]

Pre-commit is an action taken prior to committing your code into a version control system.

A pre-commit is an action that would be applied to source code before it is committed to the version control system. To utilize a pre-commit action you'll need to install a pre-commit hook into the repository. Pre-commit hooks are available in most commonly used version control systems such as SVN or git.

Some actions that could be achieved using pre-commit hooks:

  1. Fixing case issues in file names
  2. Validating file content, such as executing a linter or code convention checker.
  3. Preventing specific users from committing code

pre-commit is also the name of a framework for managing such hooks for git.

406 questions
-1
votes
1 answer

VSCode UI causes error that terminal doesn't - The hook `black` requires pre-commit version 2.9.2 but version 2.6.0 is installed

I have installed pre-commit in a virtual environment. The following error pops up whenever I use the commit button / press ctrl + enter in visual studio code. If I use the vs code terminal (WSL) then there is no problem and all the tests including…
RedBeard
  • 145
  • 2
  • 15
-1
votes
2 answers

How to make pre-commit clang-format skip over .js files?

I have the following pre-commit hook: repos: - repo: https://github.com/pre-commit/mirrors-clang-format rev: v14.0.6 hooks: - id: clang-format While in the past I have seen pre-commit skip over non-CPP files, a coworker just showed me an…
Tyler Shellberg
  • 1,086
  • 11
  • 28
-1
votes
1 answer

`npx mrm@2 lint-staged` throw err that `.git` can't be found husky custom directrory

xxx-MacBook-Pro:client xxx$ npx mrm@2 lint-staged npx: installed 239 in 8.29s Running lint-staged... /Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/bin/mrm.js:56 throw err; ^ Error: .git can't be found (see…
Mia.Zhang
  • 31
  • 6
-1
votes
1 answer

Is there any possibility to create commit message templates on azure DevOps repositories?

I just want to create some standard commit messages for repositories, is this feature available? Are there any workarounds?
CGE
  • 1
-1
votes
1 answer

define score limit for pylint with pre-commit git hook

I am trying to set a accepted pylint score limit for my pre-commit git hook. I have tried two approaches: A) adding it to the .pylintrc file [pre-commit-hook] command=custom_pylint disable=E0401, C0301 limit=8.0 B) adding it as argument to…
MadMax
  • 143
  • 4
  • 14
-1
votes
2 answers

Return error message on subprocess exit to VSCode Git

I'm in the process of implementing a little pre-commit hook that calls gitleaks protect prior to every commit. This works well in a terminal but when trying to commit from within VSCode, a non-descriptive "Git: O" is returned (I assume this is…
-1
votes
1 answer

.git/hooks/pre-commit: line 33: detekt: command not found

I am trying to use detekt on my android project but when i try to commit using sourcetree i get this error. Checking prerequisites Collecting modified files Running detekt .git/hooks/pre-commit: line 33: detekt: command not found print of the error…
-1
votes
1 answer

How do you implement commit-hooks on a repository hosted on a remote server

I created a repository on my remote server through TortoiseSVN, and I have a local working copy of that repository on my linux machine. So how do I implement my hooks? I can't seem to find the repo's directories for hooks, conf, and such. the repo's…
-1
votes
1 answer

How to display pre-commit error message

I want to force commit comment so I make a pre-commit.bat and setting under hook folder It's working well abort no comment commit message. but I have a problem that i can't see any error message from svn server. my environment is windows7 and use…
-1
votes
1 answer

SVN : Get target branch where the commit is happening in python pre-commit hook

I am writing my pre-commit hook file in python for SVN repository. I have more than one branches. I want to know from which branch the commit has come from, for example, trunk, or branch1.1 or etc. Is there any way I can find from which branch the…
Sumanth Lingappa
  • 464
  • 1
  • 6
  • 15
-2
votes
0 answers

Pre-commit error while finding branch name

I am new to pre-commit and I am trying to implement Black with pre-commit. The link to the documentation that I am following is given…
-2
votes
1 answer

Automatically re-running hook on whole repository after upgrading it

Let's say we have some hook for a tool like Black (formatter for Python). Let's say we upgrade the hook to a version of the tool that introduces significant changes to its behavior. Ideally we would want to re-run the hook on all the files in the…
Ilia Kurenkov
  • 637
  • 5
  • 12
-2
votes
2 answers

Force extension for given file type in a hook

How can I configure a pre-commit hook which will force yaml/yml files to have yaml extension. Pass: lol.yaml Fail: lol.yml
Opal
  • 81,889
  • 28
  • 189
  • 210
-2
votes
1 answer

Pre Commit Run Failing

Whenever I am trying to run pre-commit run is failing.I am getting errors in flake8,black,end of file,Validate filenames ,and trailling white spaces .My python code is from __future__ import annotations def hopkinsons_law( …
R3hankhan
  • 58
  • 1
  • 10
-2
votes
1 answer

pre-commit --comment-style regex

I have a precommit file which checks for commented line format in .cfg files. The current comment style is a semicolon, so this will fail if a pound sign is used for file comments. Can RegEx somehow be used to match multiple comment patterns? For…
GreNIX
  • 47
  • 1
  • 6
1 2 3
27
28