pre-commit-hook

Run testng test in Git pre-commit hook

左心房为你撑大大i 提交于 2019-12-23 02:21:07
问题 How would I write a bash script that will run as a git pre-commit hook to fail if a specific testng test fails? I currently run my testng tests through maven surefire like this: mvn clean test -Dtest="MyTestName" 回答1: If the pre-commit hook returns non-zero, then the commit is aborted before it even starts. In a script for a bourne style shell (e.g. sh, ksh, zsh, bash, etc.), by default the return value of the last command run is the return value of the script. As I understand it mvn clean

Why is the index not updated after doing a git add in a pre-commit hook?

纵饮孤独 提交于 2019-12-22 11:35:37
问题 I have a pre-commit hook that: checks if my version file needs to be updated modifies said file performs a git add on this file This allows me to add the updated version file to the same commit. The only problem I have is, after the hook runs the working tree and HEAD are updated with the new version file but the index isn't. I need to manually stage the version file for the index to reflect the changes. I updated git to 2.3.4 but that doesn't solve anything. Am i missing anything here?

SVN pre-commit issue

你离开我真会死。 提交于 2019-12-22 11:35:17
问题 I found this script on the net and few ppl had said that it was working for their repository. The script is to allow a pre-commit check to enforce checking of comments while checking.. The problem is I added it to the hooks directory in SVN and now all commits (even the ones with comment) are failing with this error message "Commit blocked by pre-commit (exit code 255) with no output" Now, I cannot change the script or delete it since I get the same error. Any suggestions on how to revert

Perforce client side pre-commit hook

会有一股神秘感。 提交于 2019-12-22 05:33:39
问题 We are using perforce as a source control for Visual studio solution. Working with P4 and P4V. Is it possible to add client side pre-commit hook? for instance to ensure the word "debugger;" is not exist in *.js files. Could find something in Google. Thanks. 回答1: Perforce triggers can be used to enforce such a policy, but they run in the server, not client-side. So most sites that I'm aware of would enforce a rule such as the one you describe using a change-content trigger in the server. http:

Detecting branch reintegration or merge in pre-commit script

冷暖自知 提交于 2019-12-22 03:49:20
问题 Within a pre-commit script, is it possible (and if so, how) to identify commits stemming from an svn merge ? svnlook changed ... shows files that have changed, but does not differentiate between merges and manual edits. Ideally, I would also like to differentiate between a standard merge and a merge --reintegrate . Background: I'm exploring the possibility of using pre-commit hooks to enforce SVN usage policies for our project. One of the policies state that some directories (such as /trunk )

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

南笙酒味 提交于 2019-12-21 12:12:24
问题 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 script to find and fix trailing whitespace in your commits. Bypass # it with the --no-verify option to git-commit. # detect platform platform="win" uname_result=`uname` if [[ "$uname_result" == "Linux" ]]; then platform="linux" elif [[ "$uname_result" ==

How can I run git pre-commit checks only on staged content?

牧云@^-^@ 提交于 2019-12-21 07:05:03
问题 Suppose git status gives this: # On branch X # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: file1.cc # modified: file1.h # modified: file1_test.cc # modified: SConscript # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # (commit or discard the untracked or modified content in submodules) # # modified: file1.cc # modified: tinyxml2

Testing what is about to be committed in a pre-commit hook

若如初见. 提交于 2019-12-20 18:04:25
问题 The internet is absolutely littered with incorrect and non-ideal answers to this question. This is unfortunate because you would think this would be a common thing you would want to do. The problem: When a pre-commit hook runs, the repository might not be clean. So if you naively run your tests, they will not be against what you're committing, but whatever dirt happens to be in your working tree. The obvious thing to do is to git stash --keep-index --include-untracked at the start of the pre

Pre Commit Hook for JSLint in Mercurial and Git

久未见 提交于 2019-12-20 11:48:19
问题 I want to run JSLint before a commit into either a Mercurial or Git repo is done. I want this as an automatic step that is set up instead of relying on the developer (mainly me) remembering to run JSLint before-hand. I normally run JSLint while developing, but want to specify a contract on JS files that they pass JSLint before being committed to the repo. For Mercurial, this page spells out the precommit syntax, but the only variables that seem to be available are the parent1 and parent2

Can I use a scripted commit template for git?

非 Y 不嫁゛ 提交于 2019-12-20 08:59:29
问题 We are working on tickets, and when we use the ticket number in the git commit message on the first line, then the ticket is updated with the commit message. To make things simple we always work on a branch with the commit number. Now I'd like to be presented with a commit message where the ticket number would already be filled in. It must be possible, because the branch is already in the commit template, but in comments which are removed by git. I have scoured the docs and the 'net a couple