Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vilmibm
Copy link
Contributor

@vilmibm vilmibm commented Sep 8, 2020

After mislav's feedback and talking through this with amanda I decided to go with --web just skipping all prompts. It felt wrong to do anything else messing with this myself in the terminal and now --with-token and --web are more symmetric.

The end result is something like:
image

I chose to be explicit about setting the git_protocol value so that a user gets a hint about how to change it if they desire ssh.

closes #1604

@vilmibm vilmibm requested review from mislav and samcoe September 8, 2020 21:44
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

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

This makes sense to me. Do we want to add any text to the example heredoc as well?

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.

Looks good! However, if the purpose of --web is to skip seeing prompts, if I'm reading #1604 correctly, then we have more more prompts to get rid of:

  1. If an authentication token exists and it's valid, there will be a prompt “Do you want to re-authenticate?”

    I suggest that we simply exit at this point without prompting, and pointing the user to gh auth refresh if they want to rotate their credentials.

  2. The “Choose default git protocol” prompt follows successful authentication. Should this prompt still be active in --web mode?

  3. There is also the “What account do you want to log into?”, but that prompt can already be avoided by specifying -h github.com as #1604 already points out, so we don't have to do anything about that one. It's worth keeping in mind that --web does not guarantee a prompt-free experience unless paired with --host.

@vilmibm
Copy link
Contributor Author

vilmibm commented Sep 9, 2020

My understanding was that --web was never intended to prevent all prompting; it was just one of multiple flags you could pass to affect prompting. @ampinsk could you help clarify?

@ampinsk
Copy link
Contributor

ampinsk commented Sep 9, 2020

The --web flag was intended to help skip the "How would you like to authenticate?" prompt, not necessarily in itself skipping all prompts.

However, if the user passes both the --hostname flag and the --web flag, I think we could assume that we should skip everything else (similar to what we do with gh pr create -t "title" -b "body").

Going through @mislav's points:

If an authentication token exists and it's valid, there will be a prompt “Do you want to re-authenticate?”

I suggest that we simply exit at this point without prompting, and pointing the user to gh auth refresh if they want to rotate their credentials.

👍 This makes sense to me as the behavior when both --web and --hostname are passed.

The “Choose default git protocol” prompt follows successful authentication. Should this prompt still be active in --web mode?

Let's skip this if both --web and --hostname are passed.

Does that make sense? Apologies for the lack of clarity in the original issue! 🙇‍♀️

@vilmibm vilmibm marked this pull request as draft September 10, 2020 18:51
@vilmibm vilmibm marked this pull request as ready for review September 11, 2020 18:07
@vilmibm vilmibm requested review from mislav and samcoe September 11, 2020 18:08
@vilmibm
Copy link
Contributor Author

vilmibm commented Sep 11, 2020

Updated along the lines of @mislav 's feedback after discussing with @ampinsk and playing around in the terminal; this is ready for re-review now.

@tierninho
Copy link
Contributor

I chose to be explicit about setting the git_protocol value so that a user gets a hint about how to change it if they desire ssh.

It looks to be resetting my git_protocol each time I run this cmd. Please verify as I start out with ssh then after running the new cmd, it resets to https.

➜  cli git:(web-flag) ✗ bin/gh config get -h github.com git_protocol
ssh
➜  cli git:(web-flag) ✗ bin/gh auth login -w
- Logging into github.com

! First copy your one-time code: 1DB4-04CF
- Press Enter to open github.com in your browser...
✓ Authentication complete. Press Enter to continue...

- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as tierninho
➜  cli git:(web-flag) ✗ bin/gh config get -h github.com git_protocol
https

@vilmibm vilmibm requested a review from mislav September 14, 2020 15:17
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

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

I like how this ended up with the symmetry between --web and --with-token.

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.

Amazing. Thank you for the hard work!

@vilmibm vilmibm merged commit 0c0e042 into trunk Sep 15, 2020
@mislav mislav deleted the web-flag branch October 1, 2020 18:01
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.

gh auth login --web

5 participants