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

how to let pre-commit only check the python codes you changed, not the whole file

I used pre-commit to check my python code style before I commit to git. It works very well. But now I am working on an old project, most of my work just modify several lines of the file. But pre-commit always ask me fix all the pep8 issues of the…
Gary Wang
  • 81
  • 1
  • 1
  • 4
0
votes
1 answer

pre-commit check or Remote-run missing with Github setup & Jenkins

Just to quote as an example one can submit a remote-run with some tool like TeamCity (similar to Jenkins) where it will apply delta/patch on what user is trying to commit & produces result whether changes is good from set-of configured checks for…
vinWin
  • 509
  • 1
  • 5
  • 18
0
votes
1 answer

I have a behave python test case fails during the code pre-commit

I have piece of code as this in python3 context.execute_steps( """ Given user is on the landing page When he clicks the LOGIN button And he provides the correct credential And…
user3595231
  • 711
  • 12
  • 29
0
votes
1 answer

How to write a pre-commit hook which check if txt file with version number was modifed

Every SVN project in folders tags, and trunk has version.txt file with current number of the version. I need some advice on how to write a pre-commit script that would check if the version.txt in trunk was modifed to higher version than it is in…
0
votes
1 answer

Sherter Gradle plugin for pre-commit

I am trying to add sherter gradle plugin for code style. I want to run this plugin in pre-commit script file. I added sherter in gradle as, repositories { jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath…
SmartAndroidian
  • 345
  • 5
  • 10
0
votes
1 answer

Validate commit message in git

How to validate the commit message in precommit? The commit message should be valid for the following condition. the prefix of the commit message should be like feature({A-Z}:{0-9}): 'commit message' I am a beginner for git
Akbar Basha
  • 1,168
  • 1
  • 16
  • 38
0
votes
0 answers

SVN pre-commit hook for java code compilation

This sounds to me difficult but ensuring, if it is possible to add server or local svn pre-commit hook to prevent if there are any java code compilations. Usually when there is a requirement to merge bulk of java files from higher version to lower…
name_doesnt_matters
  • 789
  • 2
  • 12
  • 34
0
votes
1 answer

pre-git's pre-commit hook is not waiting for the task to complete

Our pre-git configuration in package.json looks like "pre-git": { "pre-commit": [ "npm run lint", "npm run coverage", "npm run coverage-check" ], "post-commit": [ "git status" ] } But, the…
kallada
  • 1,829
  • 4
  • 33
  • 64
0
votes
1 answer

SVN exclude ending file extension pre-commit hook

I am trying to write a hook that blocks a commit if it has a certain string. I've gotten that working with the following code. #!/bin/sh REPOS="$1" TXN="$2" COMPARE=`$SVNLOOK diff -t "$TXN" "$REPOS"` if echo ${COMPARE} | grep -qw "path/to/file/*";…
0
votes
1 answer

Second subversion pre-commit hook not working

I am trying to add a second pre-commit script and it seems not to be catching when I place it in the hook. The first script basically locks a file from being editing. The second script look at a path and compares a string value to a file that is…
0
votes
1 answer

Is it possible to write a git pre-commit hook to permit to write 15 lines of code per method in the .net code

Is it possible to write a git pre-commit hook to permit to write only 15 lines of code per 'Method' in the .net code. I knew we can write to limit the lines of code per file, but I am not sure if we can limit the lines of code per Method in a file.
Jyothi
  • 15
  • 3
0
votes
1 answer

SVN pre-commit hook linux

I am trying to create a pre-commit hook that will search the file being committed vs a pre determined string and if it contains it then it errors out before the commit. I have the following after trying to search…
0
votes
1 answer

Git hook fails ONLY on commit

Executive summary I have a project with a custom pre-commit hook, with a tree that looks something like this: parent | - .git - hooks - pre-commit | - smoketests - argument_tests.sh | - bitshuffle.py When I run .git/hooks/pre-commit, it runs…
jyn
  • 463
  • 4
  • 16
0
votes
2 answers

(How) can I run git checkout from within the pre-commit hook?

There is a file that should be in our git repository so that it is in any checkout. It may be changed by users, but usually the changes should not be checked back in. Neither --assume_unchanged nor --skip_work_tree provide the required flexibility,…
M_M
  • 1,955
  • 2
  • 17
  • 23
0
votes
3 answers

How do i add linting to pre-commit hook

hi everyone i have a git repo that house 3 folders (individual js projects). here's my pre-commit hook #!/bin/bash echo -e "\033[1;92m Linting Staged Files . . . " files=$(git diff --diff-filter=d --cached --name-only | grep -E…
Web3 Philosopher
  • 1,296
  • 2
  • 12
  • 18