Skip to content

Add flag to login command to set name and email in global git config - #6643

Closed
samuel-adekunle wants to merge 2 commits into
cli:trunkfrom
samuel-adekunle:issue-6096
Closed

samuel-adekunle wants to merge 2 commits into
cli:trunkfrom
samuel-adekunle:issue-6096

Conversation

@samuel-adekunle

Copy link
Copy Markdown

Fixes #6096

What have I done

I added a --set-global-config flag to gh auth login command which queries the GitHub API for the necessary values and then sets the global git configuser.name and user.email keys using the retrieved values.

I believe that gh auth login was the more natural place to include this functionality rather than gh auth setup-git based on their descriptions.

Also, I set the default value of the flag to false so it won't unexpectedly change the behaviour of the command.

Testing

I tested the code locally using my own GitHub account and didn't write any additional go tests. This can be easily done by enabling the flag when running the gh auth login command.

Things I'm not sure about

According to the docs, the name can be nil and I'm not sure what to do in that case.

@samuel-adekunle
samuel-adekunle marked this pull request as ready for review November 20, 2022 01:55
@samuel-adekunle
samuel-adekunle requested a review from a team as a code owner November 20, 2022 01:55
@samuel-adekunle
samuel-adekunle requested review from samcoe and removed request for a team November 20, 2022 01:55
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Nov 20, 2022
@samcoe samcoe self-assigned this Nov 21, 2022
@samcoe

samcoe commented Jan 3, 2023

Copy link
Copy Markdown
Contributor

@samuel-adekunle Thanks for getting started on this work. I took a look at your PR today and the team decided that, despite what was said in #6096, we would like to see this feature added to the setup-git command instead of auth login. Would you be willing to make that change to this PR?

@samuel-adekunle

Copy link
Copy Markdown
Author

Hi @samcoe, I would be willing to make that change, however I can't remember if the same approach will work. I'd need to take another look at the commands (it's been a while) and then if I can, I'll add the feature to the setup-git commands.

@samuel-adekunle

samuel-adekunle commented Jan 9, 2023 •

Copy link
Copy Markdown
Author

The setup-git command now sets user.name when called, however there are still a couple things that haven't fully addressed:

  • A bit more work needs to be done for user.email because by default the authToken doesn't have the necessary scope to fetch the user's email using the API.
  • There are existing test cases that are failing and need to be resolved. They are failing due to the addition of the http client in opts which needs to be mocked.
  • Writing new test cases for the new functionality (if necessary)

@musjj

musjj commented May 24, 2023

Copy link
Copy Markdown

Any progress with this? I frequently switch accounts and this would make the process so much smoother.

@samuel-adekunle

Copy link
Copy Markdown
Author

Any progress with this? I frequently switch accounts and this would make the process so much smoother.

None so far on my end.

@jhmaster2000

Copy link
Copy Markdown

+1 this is a critically essential feature if #326 is ever to become a reality with good git integration, this really needs to be given higher priority.

@samcoe

samcoe commented Oct 18, 2023

Copy link
Copy Markdown
Contributor

After thinking about this some more and with the lack of movement here I am deciding to close this PR. Thank you @samuel-adekunle for your work and effort on this PR and I apologize that I am going to close it. I think this is mostly a failure on our team not knowing exactly what we wanted when opening the original issue up for contributions. We waffled back and forth between what command this feature should live under and never really came to a consensus. I labeled #6096 as "core" as the team wants to go back to the drawing board to come up with a more thorough plan on bringing this feature to gh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add command/flag to set user.name and user.email in global config

5 participants