question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pre-push hook shows an error

See original GitHub issue

In 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jeremymailencommented, Aug 21, 2021

Nothing to be sorry about. I am not sure how to verify a fix. I think a possible solution could be altering gradlew.path to gradlew.invariantSeparatorsPath in the gradleCommand val of GitHookTask.kt. But not sure how to verify it.

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.

1reaction
rvplauborgcommented, Aug 21, 2021

Nothing to be sorry about. I am not sure how to verify a fix. I think a possible solution could be altering gradlew.path to gradlew.invariantSeparatorsPath in the gradleCommand val of GitHookTask.kt. But not sure how to verify it.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found