Pre-push hook shows an error
See original GitHub issueIn Windows 10, you can see hook install task generate hook looks like this.
#!/bin/sh
set -e
##### KOTLINTER HOOK START #####
##### KOTLINTER 3.4.4 #####
GRADLEW=C:\Users\rlcks\workspace\freelec\gradlew.bat
if ! $GRADLEW lintKotlin ; then
echo 1>&2 "\nlintKotlin found problems, running formatKotlin; commit the result and re-push"
$GRADLEW formatKotlin
exit 1
fi
##### KOTLINTER HOOK END #####
And this shows error with message below.
.git/hooks/pre-push: line 6: C:Usersrlcksworkspacefreelecgradlew.bat: command not found
\nlintKotlin found problems, running formatKotlin; commit the result and re-push
.git/hooks/pre-push: line 8: C:Usersrlcksworkspacefreelecgradlew.bat: command not found
error: failed to push some refs to 'https://github.com/nkgcp/freelec.git'
It seems like \
in the hook file is recognized as escape character. Changing \
to \\
or /
makes it works fine.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:10 (5 by maintainers)
Top Results From Across the Web
git - Cannot push due to pre-push hook failure (exit 1)
Show activity on this post. Whenever I try to push (fast-forward), I receive an error saying: 'Pre-push hook failed: Git hook exited with...
Read more >Pipeline failures due to a 'pre-push hook already exists' error
During the repository clone stage, hooks are installed using Git LFS version specified above. If your pipeline also tries to install hooks using ......
Read more >git integration does not show local hooks output
As part of our workflow we provide various local hooks to git that output warning message etc ... Problem is with showing error...
Read more >Git hooks - pre-push doesn't show message (but pre-commit ...
With a pre-commit git hook the notification has the message ("RUN: deploy...") image2.png. And Event Log shows: 2:53 PM Commit failed with error...
Read more >Git server hooks - GitLab Docs
You can have custom error messages appear in the GitLab UI when a commit is declined or an error occurs during the Git...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
On your pull request branch you can bump version, publish to maven local, and then in your test project put
mavenLocal()
first in the repo list and pull in the version of kotlinter built by your PR. At least that’s what I usually do.The solution might be straightforward, but I always like to see a shell script run for real on the OS, make sure it doesn’t need quoting or anything else like that – still returns an exit code.
Nothing to be sorry about. I am not sure how to verify a fix. I think a possible solution could be altering
gradlew.path
togradlew.invariantSeparatorsPath
in thegradleCommand
val ofGitHookTask.kt
. But not sure how to verify it.