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.

Typically, this hook is used to protect against commits that are disallowed due to content or location (e.g. to forbid empty commit log messages).

Usually, i.e. with SVN, if the pre-commit hook program returns a nonzero exit value, the commit is aborted, the commit transaction is removed, and anything printed to stderr is marshalled back to the client.

Related tags

  • Tag may be used in combination with this tag for git specific pre-commit hooks
  • Tag may be used in combination with this tag for SVN specific pre-commit hooks
626 questions
9
votes
3 answers

Git hook, modify commit files

I'm trying to write a Git pre-commit hook script. It should write the date of commit at the beginning of modified files. My problem is that I can't add modified files to the previous commit. When I am trying invoke to a Git commit again, it runs…
SerCe
  • 5,826
  • 2
  • 32
  • 53
9
votes
3 answers

Use gruntjs as precommit hook

Is there a way to run a gruntjs task as precommit hook. For example I want do prevent commits with failing tests or jshint issues. I've also think about to run a code beautifier for every commit.
Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297
9
votes
2 answers

How to enforce Coding Standard for the repository located in GIthub

We have an account in Github and hosts all of our projects in Github (private repositories). We want to enforce coding-standard and probably other hooks that we use for internal purpose. We have had these hooks work pretty well for subversion since…
Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66
8
votes
4 answers

How do I block php debug output from being committed in svn?

I would like to block debug functions var_dump, print_r, etc... from being commited to the repo so that QA can go over things and not report bugs like "There is a huge block of text on all of the pages!!" I have tried regex (not a great idea...…
SeanJA
  • 10,234
  • 5
  • 32
  • 42
8
votes
2 answers

SVN Pre-commit hook to be triggered for a particular folder

One of our client's SVN repository has quite a bunch of projects under the single repository. Now I want to check coding-standard for one of the project via pre-commit hook. If I configure the pre-commit, it is going to affect all the projects…
Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66
8
votes
1 answer

Package requires a different Python: 2.7.17 not in '>=3.6.1' while setting up pre-commit

I cloned a repository, installed pre-commit and was committing for the first time. This is the time when pre-commit packages actually get installed and setup. I faced the following issue. [INFO] Installing environment for…
Roopak A Nelliat
  • 2,009
  • 3
  • 19
  • 26
8
votes
3 answers

git clone different repository in git hooks creating trouble

We have a specific requirement in which we have to push all files which arrive for being committed to a certain branch. We are planning to achieve this via git hooks specifically commit-msg hook. While doing so what we do is we clone branch to…
Jatin Dhoot
  • 4,294
  • 9
  • 39
  • 59
8
votes
1 answer

Pylint ignore file with git-pylint-commit-hook

Im using pylint 1.6.4 and git-pylint-commit-hook 2.1.1 to lint my files on pre-commit. I also use alembic to generate my migrations, they are stored in /migrations/versions. The problem is that the generated migrations are not valid…
Jakub Tesárek
  • 136
  • 1
  • 6
8
votes
1 answer

Organize imports of java files using eclipse from command line

I want to format java code and organize the imports in the pre-commit hook using command line, When i searched how to do this i found this link which explains how to format the code using eclipse from command line as the following: eclipse…
Mahmoud Adam
  • 5,772
  • 5
  • 41
  • 62
8
votes
1 answer

Can git pre-receive hooks evaluate the incoming commit?

I'm trying to write a server side pre-receive git hook to evaluate commits as they are being pushed. According to the answers here, this should easily be possible by searching git log and filtering out what I want with 'format:'. I've created the…
spuder
  • 17,437
  • 19
  • 87
  • 153
8
votes
1 answer

Does NetBeans ignore my Git pre-commit hook?

I am trying to use a pre-commit hook for Git. The hook looks like the following: #!/bin/bash echo "fail" exit 1 Thus, it will always fail, i.e. my Git commit should fail. If I add something with git and then commit it in the commandline I nicely…
meijuh
  • 1,067
  • 1
  • 9
  • 23
7
votes
2 answers

The hook `black` requires pre-commit version 2.9.2 but version 2.6.0 is installed

I am having trouble with pre-commit and black. Everything worked fine until I cleared the cache with pre-commit clean. Now I always get the error The hook black requires pre-commit version 2.9.2 but version 2.6.0 is installed. Perhaps run `pip…
shadow
  • 151
  • 2
  • 12
7
votes
1 answer

pre-commit hook to check django migrations

I'm trying to write a pre-commit hook to my Django project that checks for missing migrations. That is, it ensures all changes are reflected in a migrations file. One way to implement this is to PASS the pre-commit hook if the makemigrations command…
Johnny Metz
  • 5,977
  • 18
  • 82
  • 146
7
votes
4 answers

Why isn't my git pre-commit hook trimming white space from the end of lines?

I'm on Mac Mojave. I have created a file at ~/.git-templates/hooks/pre-commit , which I wanted to remove white space from the end of lines in files I'm committing. I would like this to happen globally, across all of my projects. # A git hook…
Dave
  • 15,639
  • 133
  • 442
  • 830
7
votes
1 answer

Gitlab pre-commit hook

I would like to use pre-commit hook in gitlab. I doing everything like in documentation: https://docs.gitlab.com/ce/administration/custom_hooks.html In custom_hooks directory I've created pre-commit file with folowing content: #!/bin/bash exit…
Robert Grądzki
  • 139
  • 1
  • 2
  • 8