I use this script in pre-commit hook to make some checks before I push the changes to git.
#!/bin/bash
mvn clean compile -DskipTests &> $TEMP/cc.txt &
A=$!
wait $A
A=$?
if test "$A" != "0"
then
cat $TEMP/cc.txt
exit 1
fi
mvn javadoc:javadoc -T 8 &> $TEMP/jd.txt &
B=$!
mvn pmd:cpd-check &> $TEMP/pmd.txt &
C=$!
mvn org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report -T 8 &> $TEMP/jcc.txt &
D=$!
mvn checkstyle:checkstyle -Dcheckstyle.config.location=https://XXXX &> $TEMP/cs.txt &
E=$!
wait $B
B=$?
wait $C
C=$?
wait $D
D=$?
wait $E
E=$?
mvn sonar:sonar -Dsonar.host.url=https://sonarcubeXXXX &> $TEMP/cq.txt &
F=$!
wait $F
F=$?
echo "compile $A, javadoc $B, pmd $C, jacoco $D, checkstyle $E, sonar $F"
if test "$A$B$C$D$E$F" != "000000"
then
if test "$D" != "0"
then
cat $TEMP/jcc.txt
fi
if test "$F" != "0"
then
cat $TEMP/cq.txt
fi
exit 1
fi
exit 0
But as long as the pre-commit-hook is running (5 minutes), I can not work and change sourcefiles.
I use Sourcetree to commit, sourcetree makes a difference between staged and unstaged files. While commiting files sourcetree executes this command:
git -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -F C:\Users\XXXX\AppData\Local\Temp\fbox5amv.k5f
How to access the intended codebase (what is currently pushed + what I have staged and try to commit) only but not the changes that are not staged in Sourcetree?
I have used subversion-commit-hooks before, they are server-side and they was able to extract the prospective codebase only.
Any idea?
As there was no other answer there might be no way to access staged+committed+pushed changes without the unstaged changes before a commit(ment) has been made.
Therefore I had to change from a pre-commit hook to a post-commit
hook and change the script to this:
#!/bin/bash
rm -rf ../committed
mkdir ../committed
cp -rf * ../committed/
cd ../committed
git stash save -u
mvn clean compile -DskipTests &> $TEMP/cc.txt &
(...)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.