File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,4 +112,9 @@ ln -s ../../pre-commit.sh .git/hooks/pre-commit
112112```
113113
114114This will only allow commits if the tests pass. It is also a good reminder to keep the test suite
115- short.
115+ short.
116+
117+ Note: the tests run on the current state of the working directory. I tried to add a `git stash` in
118+ the script to only test what' s actually being committed, but I couldn' t get it to run reliably
119+ (it' s still in there but commented). Keep this in mind when you commit, and don' t forget to re-add
120+ the changes if the first attempt failed and you fixed the tests.
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- STASH_NAME=" pre-commit-$( date +%s) "
4- git stash save --keep-index $STASH_NAME
3+ # STASH_NAME="pre-commit-$(date +%s)"
4+ # git stash save --keep-index $STASH_NAME
55
66mvn clean test
77RESULT=$?
88
9- STASHES=$( git stash list)
10- if [[ $STASHES == * $STASH_NAME * ]]; then
11- git stash pop
12- fi
9+ # STASHES=$(git stash list)
10+ # if [[ $STASHES == *$STASH_NAME* ]]; then
11+ # git stash pop
12+ # fi
1313
1414[ $RESULT -ne 0 ] && exit 1
1515exit 0
You can’t perform that action at this time.
0 commit comments