Closed simeon-smith closed 5 years ago
Can't reproduce.
$ cat > package.json <<EOF
{
"scripts": {
"doit": "echo"
},
"git": {
"pre-commit": ["doit"]
}
}
EOF
$ git init
$ npm i @zeit/git-hooks
$ git add -A
$ git commit -m "initial commit"
△ run hook: pre-commit -> doit
> @ doit /private/tmp/git-hooks
> echo
[master 5f1baa0] fix
1 file changed, 1 insertion(+), 1 deletion(-)
Closing this as I cannot reproduce. Let me know if you're still seeing this.
I am seeing something like this. It started tacking "origin branch-name" onto my git-pre-push commands, presumably because it's getting them from git somehow. It didn't do this until recently. I'm not sure what changed.
Nothing has changed on our end. If you can come up with reproduction steps I can issue a fix :)
What's your git version? I think this only happens with new git:
$ git version
git version 2.26.0
$ yarn --version
1.22.4
2.25.0. I think this is very much related to local configuration - something we should fix, but I don't think it has to do with a change in Git.
Well, I wasn't seeing it on my old laptop, a new developer started using the project and he saw it, and then I set up a new laptop and I started seeing it. Can you try 2.26.0 and see if anything changes for you?
I uninstalled and reinstalled the hooks on github.com/spotlightpa/poor-richard on the laptop with old git (2.21.0) and now it's having the problem too, so I guess it's not the git version. You can try cloning the repo and see if that works as a test case for you.
△ run hook: pre-push -> git-pre-push
> poor-richard@0.0.1 git-pre-push /src/spotlightpa/poor-richard
> yarn run test "qix-" "git@github.com:Qix-/poor-richard"
yarn run v1.19.1
$ yarn run test:eslint && yarn run test:prettier qix- git@github.com:Qix-/poor-richard
$ eslint --ext .js,.vue --ignore-path .gitignore .
$ prettier --ignore-path .gitignore --check **/**/*.{scss,js,yml,vue} qix- git@github.com:Qix-/poor-richard
Checking formatting...
[error] No files matching the pattern were found: "qix-".
[error] No files matching the pattern were found: "git@github.com:Qix-/poor-richard".
All matched files use Prettier code style!
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! poor-richard@0.0.1 git-pre-push: `yarn run test "qix-" "git@github.com:Qix-/poor-richard"`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the poor-richard@0.0.1 git-pre-push script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/anonymous/.npm/_logs/2020-04-17T02_22_10_748Z-debug.log
error: failed to push some refs to 'git@github.com:Qix-/poor-richard'
Assuming the errors aren't the problem, I don't see where a 0
is being tagged on.
It's not adding a 0 for me. That was @simeon-smith's issue. My issue is that it's adding "qix-" "git@github.com:Qix-/poor-richard"
, which are presumably the git names for the branch and remote. So in your output it says yarn run test:eslint && yarn run test:prettier qix- git@github.com:Qix-/poor-richard
when it should just say yarn run test:eslint && yarn run test:prettier
. This leads to a false error where prettier is confused that it can't find any files named like the branch and remote.
Sorry if I should have opened a new issue. My guess is that this was related (adding something to the test command), but it might be unrelated.
Ah yes, please open a new issue.
When I created a command it tags a "0" onto the end of the command. For a temporary fix I just added echo to the end of my command so it doesn't fail.
Example
unset ZEIT_GITHOOKS_RUNNING ; if npx git-branch-is master ; then npm version patch && git push && git push --tags ; fi ; echo