Repository navigation
gh auth setup-git requires a login #8521
Description
Activity
@jtnord Thanks for writing in. I think you make a good point in that allowing
auth setup-gitto be run before authenticating is useful for doing pre-setup of developer environments. It should be simple enough to add theskipAuthCheckannotation to theauth setup-gitcommand, going to open this up for contributions.- addedpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetichelp wantedContributions welcomeContributions welcomegh-authrelating to the gh auth commandrelating to the gh auth commandand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Jan 4, 2024 mustafateke535 commented
on Jan 4, 2024 on Jan 4, 2024 via email · Hidden as spamshow commentMore actions@samcoe I don't think this is related to
skipAuthCheckbut that the command itself asserts this?I agree that if you provide the
hostnameflag that this check doesn't need to be enforced.I think if you were to run it with no logged in hosts it should either continue to do what it does, or default to github.com (which is essentially the only known host). In the absence of a good reason to default it, I'd say leave it as it is.
@williammartin Thanks for the correction, 🤦, I did not actually look at the code and just assumed it was using the same
skipAuthCheckmechanism other commands are using.I concur that the auth check should only be skipped if the
hostnameflag is provided.@jtnord @samcoe on reviewing this a bit more, I wonder whether it might be better to provide a
--forceflag in combination with `--hostname"?There's still some advantage to the current behaviour where running
setup-git --hostname github.conprovides a useful error. In the case where you really, really want to add a credential helper for an unknown host, then you can opt in to--force. WDYT?Reacted by James Nord@williammartin I think that is a good suggestion. I am on board with that approach 👍
This has been merged into
trunkif you'd like to try it. Our release cadence is roughly every two weeks and we released yesterday. It may go out next week at the earliest. Thanks everyone for your contributions!Reacted by James Nord
Describe the bug
gh auth setup-gitshould be used to configure the github credential helper (basicallygit config --global credential.https://github.com.helper !'$PATH_TO_GH.EXE' auth git-credentialhowever the command fails withYou are not logged into any GitHub hosts. Run gh auth login to authenticate.as the command is purely configuring git there should be no requirement for it to be logged in. this causes pain where the command is being run to pre-setup developer environments but leaves the login to the user at a later date (when it is needed)
Steps to reproduce the behavior
gitandghgh auth setup-git --hostname github.comgit config --global -lExpected vs actual behavior
the command in step 2 runs without error
the command in step 3 shows that the helper has been added
Actual behaviour is the second command fails
> gh auth setup-git --hostname github.com You are not logged into any GitHub hosts. Run gh auth login to authenticate.Logs