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
0
votes
1 answer

Checking for specific string in commit message - SVN Precommit Hook

I am expecting the following format in the svn commit message. Description: (some description of the change) Entity: (change request number) If the comment while committing doesn't follow the above format an error message should be thrown. The…
ramz
  • 168
  • 2
  • 6
  • 16
0
votes
1 answer

SVN Hook “Could not MERGE resource” and Access Denied Error

I’ve got an SVN hook written as a .NET console app and running on VisualSVN server which is causing some problems. Every time I try to commit (either remotely with Tortoise or locally via command line) I get the response “Access Denied”. Looking at…
Troy Hunt
  • 20,345
  • 13
  • 96
  • 151
0
votes
1 answer

how to check in pre-commit file to git repository

I try to add a new pre-commit in myrepo/.git/hooks/pre-commit. How come I don't see this pre-commit new file when I run git status Some git configuration or setting I need to turn on? THanks
icn
  • 17,126
  • 39
  • 105
  • 141
-1
votes
0 answers

SQLFLUFF doesn't parse dbt macros to fix even though they are not ignored in .sqlfluffignore

I have a dbt project which I wanna lint with SQLFLUFF and it consists of models and macros in which model calls macros as normal. Most of SQL codes are in macro files and models just simply call the relative macro. The problem here is that SQLFLUFF…
Masoud
  • 1
  • 3
-1
votes
1 answer

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 inside the directory showing this…
-1
votes
1 answer

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", "--output-file", "README.md", "./"] - repo:…
-1
votes
1 answer

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. Additional context (to answer questions…
nnay84
  • 167
  • 1
  • 12
-1
votes
1 answer

mypy via pre-commit - Duplicate module name 'package.module.py' (and 'package\module.py')

I have the following repo-structure my-repo/ .github/ linters/ .mypy.ini .pre-commit-config.yaml mypackage/ __init__.py main.py subpackage/ __init__.py foo.py …
tenticon
  • 2,639
  • 4
  • 32
  • 76
-1
votes
1 answer

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 additional_dependencies: - stylelint …
meAndrew
  • 144
  • 1
  • 13
-1
votes
1 answer

Git pre-commit hooks don't trigger on Mac

I'm learning about pre-commit hooks and I can't seem to get them to run I'm running git 2.40.1 on Mac OS Monterey 12.6.5 This is the content of my .git/hooks directory in the root of my demo project Meanwhile, this is the local .git/config file…
LizCiraG
  • 57
  • 4
-1
votes
2 answers

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 commit. If i try to commit again i get the same…
Fanto
  • 377
  • 3
  • 14
-1
votes
1 answer

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 like interrogate to act as a verbose warning instead…
Identicon
  • 33
  • 4
-1
votes
1 answer

Pre-commit: Absolutify-imports vs Pylint: E0402: Attempted relative import beyond top-level package

Context Suppose the folder structure is used: apples/ src/ __init__.py apples/ helper.py __main__.py __init__.py tests/ __init__.py sometest.py This structure is analog to…
a.t.
  • 2,002
  • 3
  • 26
  • 66
-1
votes
1 answer

I can't exlude the directory from my pre-commit

My goal it's exlude migrations/ from my pre-commit. I have my .pre-commit-config.yaml which begin with repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: check-yaml - id: debug-statements …
-1
votes
2 answers

Make pre-commit check in subdirectory of repository?

I'm trying to get a pre-commit check to run a command (in npm) not in the root of the git repository (I have a folder "frontend" that contains the npm installation). This sounds trivial, but so far I have found no pre-commit package that supports…
Mark
  • 45
  • 4