Repository navigation
Is there a way to pass --no-verify when creating a PR? #684
Description
Activity
Hi, thanks for the suggestion!
During
pr create, the only git command that we shell out to isgit push. Therefore the only git hook that I can imagine running is thepre-pushhook. We don't create commits, so I'm confused as to howpre-commitandcommit-msgare running for you. Could you check whether some of your git hooks invoke other hooks?We did not have a plan to support
--no-verify, but we do have a plan to respect an already-pushed branch. That way, if you do something like this, gh wouldn't shell out to git at all:git push --no-verify <remote> HEAD gh pr create
Would this be sufficient?
Reacted by Jasha Sommer-Simpson- addedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on Mar 20, 2020 Sorry, I meant pre-push hooks.
I was just hoping I can do it all through
ghinstead of having to push the branch viagitwith the--no-verifyflag and then creating the PR throughghas you suggested.Hope you consider that in the future. Thank you!
- removedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on Mar 25, 2020 I was just hoping I can do it all through
ghinstead of having to push the branch viagitwith the--no-verifyflagThat makes sense. We will consider supporting a flag such as
--no-verify. But it's likelier that before that we already ship a fix that respects if a branch has been manually push, which at least gives you a temporary workaround.Reacted by Wael Hamdan and Jasha Sommer-SimpsonWe did not have a plan to support
--no-verify, but we do have a plan to respect an already-pushed branch. That way, if you do something like this, gh wouldn't shell out to git at all:git push --no-verify <remote> HEAD gh pr create
Just a note that the feature described here just landed in master and is slated for release this week. No plan yet for adding
--no-verifytogh pr createyet, but we will keep this and related requests in mind!Hi ! Unfortunately, the fix #704 doesnt seem to be working as expected.
I am doing the following to create a PR using
ghand making my commits and push usinggit, since there is no way to pass--no-verifyingh pr create.$ git push --no-verify -u origin $BRANCH_NAME $ gh pr createBut in the output, I can still see the pre-push hooks running for
gh pr create... Creating pull request for $BRANCH_NAME into master in $REPO_NAME husky > pre-push (node v12.16.2) ...The branch is successfully created on Github, since I am passing
--no-verifyflag withgit push. However, creating a PR is failing because I cannot pass the--no-verifyflag withgh pr createI am using the latest version of
gh cli$ gh --version gh version 0.11.1 (2020-07-28) https://github.com/cli/cli/releases/tag/v0.11.1@nl-ria Thank you for reporting!
I just tried to reproduce this using the commands you provided, and I couldn't, but it's still possible that there is a bug here. If you use the
DEBUG=1environment variable when runninggh, you will get verbose output that should include all underlying invocations ofgit. Can you share with us the output? (You may anonymize branch names.)@mislav - thanks for getting back so quickly, here is output in debug mode
Running command
$ gh pr create --title "$title" --body "$body"Output
[git remote -v] * Request at 2020-08-17 13:12:38.706138 +0100 BST m=+0.037714513 * Request to https://api.github.com/graphql * Request took 811.334796ms [git symbolic-ref --quiet --short HEAD] [git config --get-regexp ^branch\.$BRANCH_NAME\.(remote|merge)$] [git show-ref --verify -- HEAD refs/remotes/origin/$BRANCH_NAME refs/remotes/origin/$BRANCH_NAME] * Request at 2020-08-17 13:12:39.546963 +0100 BST m=+0.878513929 * Request to https://api.github.com/graphql * Request took 380.311856ms [git status --porcelain] [git -c log.ShowSignature=false log --pretty=format:%H,%s --cherry origin/master...$BRANCH_NAME] [git -c log.ShowSignature=false show -s --pretty=format:%b e66d5583a31bc87298d4b8a62daa9922531226fa] * Request at 2020-08-17 13:12:40.014256 +0100 BST m=+1.345793091 * Request to https://api.github.com/graphql * Request took 300.451734ms Creating pull request for $BRANCH_NAME into master in $REPO_NAME [git push --set-upstream origin HEAD:$BRANCH_NAME] husky > pre-push (node v12.16.2) .... runs the pre-push github hooks and fails as expected .... husky > pre-push hook failed (add --no-verify to bypass) error: failed to push some refs to '$REPO_NAME' exit status 1@nl-ria Thank you for the debug output!
Nothing stands out to me as potentially wrong in the log. 😕 Could you check the output of
git show-ref --verify -- HEAD refs/remotes/origin/$BRANCH_NAME refs/remotes/origin/$BRANCH_NAMEafter you put in your actual branch name? It should be something like this, where you can see that the commit SHAs are identical:$ git show-ref --verify -- HEAD refs/remotes/origin/"$(git branch --show-current)" 27b0c83f1c1f2d6e705426cf1d3926f0c5b1fa47 HEAD 27b0c83f1c1f2d6e705426cf1d3926f0c5b1fa47 refs/remotes/origin/gh-pre-push-testAnd also please your
git version🙇oh, interesting, not sure why, but getting an error when trying to get the output of the above command
$ git show-ref --verify -- HEAD refs/remotes/origin/$BRANCH_NAME refs/remotes/origin/$BRANCH_NAMEOutput
e66d5583a31bc87298d4b8a62daa9922531226fa HEAD fatal: 'refs/remotes/origin/$BRANCH_NAME' - not a valid refCould you explain what this command means? I can see the same commit SHA on Github on $BRANCH_NAME, so not quite sure why its erring on my local machine.
My Git version :
$ git --version git version 2.28.0@nl-ria What usually happens when you do something like
git push origin mybranchis that git performs the push, but also creates what it calls a "remote-tracking branch". In this case, the remote-tracking branch is calledorigin/mybranchfor short, but the fully qualified ref name for it would berefs/remotes/origin/mybranch.Your git push obviously succeeded, but the remote-tracking branch was not created and thus gh could not detect that the branch was already pushed. I'm not sure why is that, but it could be due to unconventional
git config --get-all remote.origin.fetchconfiguration, or some other factors.In any case, it's clear to me from your and other people's reported cases that we need an explicit option to disallow the auto-fork/auto-push behavior so that we don't rely on brittle detection mechanisms. Thank you for your input! Unfortunately, I do not have a suitable workaround to suggest right now.
Sometimes I would like to be able to create a PR without running the
pre-commitandcommit-msgpre-push hooks when pushing the changes. Is that possible?Edit: Replaced pre-commit and commit-msg with pre-push.