Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better in use on windows ? #3

Open
abcfy2 opened this issue May 6, 2019 · 5 comments
Open

Better in use on windows ? #3

abcfy2 opened this issue May 6, 2019 · 5 comments

Comments

@abcfy2
Copy link

abcfy2 commented May 6, 2019

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
@abcfy2
Copy link
Author

abcfy2 commented May 6, 2019

Maybe you can use cygpath -m to mix path both for windows and posix

@STAR-ZERO
Copy link
Owner

Sorry, I don't have a Windows. I can't check. 🙇

@abcfy2
Copy link
Author

abcfy2 commented May 6, 2019

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.

@Murik
Copy link

Murik commented Aug 20, 2020

any news?

@STAR-ZERO
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants