gradle-githook
gradle-githook copied to clipboard
Better in use on windows ?
If I use powershell, git hook shows:
error: cannot spawn .git/hooks/pre-commit: No such file or directory
But .git/hooks/pre-commit is existed.
PS cat .git/hooks/pre-commit
#!/bin/sh
# gradle-githook
C:\Users\abcfy\projects\dteam-top\clock-seed\gradlew codenarcMain pmdMain spotbugsMain
[ $? -gt 0 ] && exit 1
...
And if I use Cygwin/Msys2/Mingw, git hook shows:
.git/hooks/pre-commit: line 4: C:Usersabcfyprojectsdteam-topclock-seedgradlew: command not found
Maybe you can use cygpath -m to mix path both for windows and posix
Sorry, I don't have a Windows. I can't check. 🙇
I solved by myself, just solve the path for posix, and windows git could also works very well(Use git for windows cmd/git).
Here is my sample:
.git/hooks/pre-commit:
#!/bin/sh -e
echo $@
[ -f ./gradlew -o -f ./gradlew.bat ] && GRADLE=./gradlew || GRADLE=gradle
$GRADLE codenarcMain pmdMain spotbugsMain
.git/hooks/commit-msg:
#!/bin/sh -e
commitlint -x @commitlint/config-conventional -e $@
/bin/sh -e will automatic exited when the line not exit with 0, and [ -f ./gradlew -o -f ./gradlew.bat ] && GRADLE=./gradlew || GRADLE=gradle could solve the gradle wrapper not exist.
any news?
Sorry, I'm too late.
Maybe, I fixed this issue. But I'm not. Please check version 1.2.1.
I am not familiar with Windows. If you have a problem with Windows, I want you to send a pull request. It's very helpful.