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

Problem with the pre-push git hook #646

Closed
tzeikob opened this issue Jan 14, 2020 · 14 comments
Closed

Problem with the pre-push git hook #646

tzeikob opened this issue Jan 14, 2020 · 14 comments

Comments

@tzeikob
Copy link

tzeikob commented Jan 14, 2020

After installing the husky latest version (4.0.9) and setting the following hooks in the package.json file,

...
"husky": {
    "hooks": {
      "pre-push": "npm run test"
    }
  }
...

each time I try to push to the origin I'm getting the following error having my push aborted,

git push -u origin master
.git/hooks/pre-push: 70: export: refs/heads/master: bad variable name
error: failed to push some refs to 'git@bitbucket.org:tzeikob/husk.git'

OS: Ubuntu 18.04 LTS

HUSKY_DEBUG=1 npm install husky --save-dev

> husky@4.0.9 install /home/akis/Workspace/sources/temp/husk/node_modules/husky
> node husky install

husky > Setting up git hooks
husky:debug Current working directory is /home/akis/Workspace/sources/temp/husk/node_modules/husky
husky:debug INIT_CWD is set to /home/akis/Workspace/sources/temp/husk
husky:debug Git rev-parse command returned:
husky:debug   --git-common-dir: .git
husky:debug   --show-prefix: 
husky:debug Package manager: npm
husky:debug Installing hooks in /home/akis/Workspace/sources/temp/husk/.git/hooks
husky > Done

> husky@4.0.9 postinstall /home/akis/Workspace/sources/temp/husk/node_modules/husky
> opencollective-postinstall || exit 0
HUSKY_DEBUG=1 git push -u origin master
husky:debug husky v4.0.9 (created at 2020-1-14 8:55:17 PM)
husky:debug pre-push hook started
husky:debug Current working directory is /home/akis/Workspace/sources/temp/husk
husky:debug pre-push hook started
.git/hooks/pre-push: 70: export: refs/heads/master: bad variable name
error: failed to push some refs to 'git@bitbucket.org:tzeikob/husk.git'
@jeffborg
Copy link

I'm getting exactly the same thing on push, on mint but same Ubuntu 18.04 version basically

@soda0289
Copy link

Looks like it broke in 4.0.9 by #645

If I delete the new case statement from .git/hooks/pre-push it works

case $hookName in
  "pre-push"|"pre-receive"|"post-receive"|"post-rewrite")
    export HUSKY_GIT_STDIN=\`cat\`;;
esac

@soda0289
Copy link

soda0289 commented Jan 14, 2020

I think it needs to have quotes (") like:

case $hookName in
  "pre-push"|"pre-receive"|"post-receive"|"post-rewrite")
    export HUSKY_GIT_STDIN="`cat`";;
esac

Since bash will throw an error when u do something like: export FOO= foo/bar/baz since foo/bar/baz is not defined and there is a space after equals

Also if I just do an echo ``cat`` it prints:
HEAD d37e414464dead83502ddfe2978cf25a7a3499c8 refs/for/master 0000000000000000000000000000000000000000 which has spaces and is most likly causing the issue.

@mikehardy
Copy link

I am seeing this as well, if I just change the shebang at the top to use #!/bin/bash in lieue of #!/bin/sh it works?

@wendellpbarreto
Copy link

wendellpbarreto commented Jan 15, 2020

I'm getting the same problem when using WSL with Ubuntu 18.04

@lcnogueira
Copy link

I'm facing exactly the same problem as well.

@lcnogueira
Copy link

BTW, I think @soda0289 is right: it has broken in 4.0.9 version. I tried to use the 4.0.7 one and it works. The maintainer will probably solve it as soon as he realizes it.

jo12bar added a commit to jo12bar/cv that referenced this issue Jan 15, 2020
@nithinkr1shna
Copy link

I am also having the same issue, downgrading to 4.0.7 appears to work.

@millette
Copy link

Meanwhile, this works:

git push --no-verify

I think we should keep sh compatibility (don't fix with /bin/bash please).

@zarabotaet
Copy link

for me 3 version instead 4 is worked normally.
Windows10 WSL2 Ubuntu 18.04

@mikehardy
Copy link

@millette for the record I agree totally, changing to /bin/bash is not a solution I recommend, was just offering another option to people to unstick themselves in case it was useful. I've pinned my dependency on this module to 4.0.7 pending discussion here. Cheers :-)

@typicode
Copy link
Owner

As @soda0289 pointed out, it was missing a ". A new version (4.0.10) has been released with the fix. Thanks again 👍

@mikehardy
Copy link

Love husky, thanks @typicode

@tzeikob
Copy link
Author

tzeikob commented Jan 15, 2020

Issue has been addressed in version 4.0.10.

@tzeikob tzeikob closed this as completed Jan 15, 2020
WB-15 pushed a commit to WB-15/vuetify-module that referenced this issue Oct 9, 2023
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

10 participants