Skip to content

Check path for git executable before auth#4109

Merged
mislav merged 2 commits intocli:trunkfrom
shaharyarahmed-bot:dev
Aug 11, 2021
Merged

Check path for git executable before auth#4109
mislav merged 2 commits intocli:trunkfrom
shaharyarahmed-bot:dev

Conversation

@shaharyarahmed-bot
Copy link
Contributor

There was a bug where if git was not installed then gh would do its
authentication and try to configure git but would then find out that the
git executable was not in PATH.

Now gh checks to see if the git executable is in PATH before
authenticating the user. If the git executable is in PATH the
authentication continues as normal, if it is not in PATH then it prints
out an error to the console:

$ git executable not found in $PATH

Fixes #3818

@mislav mislav self-requested a review August 11, 2021 14:24
shaharyarahmed-bot and others added 2 commits August 11, 2021 19:22
There was a bug where if git was not installed then gh would do its
authentication and try to configure git but would then find out that the
git executable was not in PATH.

Now gh checks to see if the git executable is in PATH before
authenticating the user. If the git executable is in PATH the
authentication continues as normal, if it is not in PATH then it prints
out an error to the console:

$ git executable not found in $PATH

Resolves: cli#3818
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Your solution was good, but it involved checking git presence at the start of the command, before it's known whether git will be needed at all. As far as I can tell, git is only needed if you chose “yes” for the step “Authenticate git with your GitHub credentials”.

I've pushed some updates so that the experience is like this now:

$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
unable to find git executable in PATH; please install git before retrying

@mislav mislav enabled auto-merge August 11, 2021 17:26
@mislav mislav merged commit c39dd1e into cli:trunk Aug 11, 2021
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

Successfully merging this pull request may close these issues.

GitHub CLI should check PATH for git.exe *before* it does the whole auth thing

2 participants