Skip to content

Conversation

@rajhawaldar
Copy link
Contributor

Fixes: #8430

@rajhawaldar rajhawaldar requested a review from a team as a code owner February 3, 2024 17:49
@rajhawaldar rajhawaldar requested review from andyfeller and removed request for a team February 3, 2024 17:49
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Feb 3, 2024
@andyfeller
Copy link
Member

andyfeller commented Feb 6, 2024

@rajhawaldar : thank you for opening this PR and contributing to the GH CLI! ❤️

I built this branch locally for testing purposes, however it doesn't do exactly what I'd think based on the issue and my testing setup:

cli/cli ‹show-host-name-in-repo-creation›$ make               
go build -trimpath -ldflags "-X github.com/cli/cli/v2/internal/build.Date=2024-02-06 -X github.com/cli/cli/v2/internal/build.Version=v2.43.1-9-gf6dd5c4c " -o bin/gh ./cmd/gh
andyfeller@Andys-MacBook-Pro:cli/cli ‹show-host-name-in-repo-creation›$ ./bin/gh repo create
? What would you like to do?  [Use arrows to move, type to filter]
> Create a new repository on github.com from scratch
  Create a new repository on github.com from a template repository
  Push an existing local repository to GitHub

cli/cli ‹show-host-name-in-repo-creation›$ gh auth switch
? What account do you want to switch to? andyfeller (ghe.io) - active
✓ Switched active account for ghe.io to andyfeller

cli/cli ‹show-host-name-in-repo-creation›$ gh auth status
github.com
  ✓ Logged in to github.com account andyfeller_volcano (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: ************************************

  ✓ Logged in to github.com account andyfeller (keyring)
  - Active account: false
  - Git operations protocol: https
  - Token: ************************************

ghe.io
  ✓ Logged in to ghe.io account andyfeller (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: ************************************

cli/cli ‹show-host-name-in-repo-creation›$ ./bin/gh repo create
? What would you like to do?  [Use arrows to move, type to filter]
> Create a new repository on github.com from scratch
  Create a new repository on github.com from a template repository
  Push an existing local repository to GitHub

Since I switched hosts, I would have expected this to show ghe.io being my active user 🤔 ... I imagine the issue being on an active account that has both GitHub.com and GHES presence as setting GH_HOST reflects the host as expected:

$ GH_HOST=ghe.io ./bin/gh repo create
? What would you like to do?  [Use arrows to move, type to filter]
> Create a new repository on ghe.io from scratch
  Create a new repository on ghe.io from a template repository
  Push an existing local repository to GitHub

"Create a new repository on GitHub from a template repository",
"Create a new repository on " + hostname + " from scratch",
"Create a new repository on " + hostname + " from a template repository",
"Push an existing local repository to GitHub",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Push an existing local repository to GitHub",
"Push an existing local repository to " + hostname,

Additionally, this will break tests, too.

Copy link
Member

Choose a reason for hiding this comment

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

Which tests? All tests seem to be passing.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, let me rephrase that:

"Making this change will require making additional changes in tests"

return prompter.IndexFor(options, "Push an existing local repository to GitHub")

return prompter.IndexFor(options, "Push an existing local repository to GitHub")

@andyfeller
Copy link
Member

@williammartin : would like your 👀 on this too given the multi-host angle and behavior when on GitHub.com and GHES.

@williammartin
Copy link
Member

@andyfeller, gh auth switch switches users on a particular host, it has no bearing on what host your commands will target. If you were to log out of both your github.com accounts (or use GH_HOST as you noticed already) this would work as expected I think.

{
name: "interactive create from scratch with gitignore and license",
opts: &CreateOptions{Interactive: true},
name: "interactive create from scratch with gitignore and license",
Copy link
Member

Choose a reason for hiding this comment

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

@rajhawaldar : any concerns about extending the tests to include a version of this test that overrides GH_HOST like what is done in other tests to ensure a host other than github.com results?

@williammartin
Copy link
Member

Gentle nudge on this @rajhawaldar. Is this still something you're interested in working on?

@rajhawaldar
Copy link
Contributor Author

Gentle nudge on this @rajhawaldar. Is this still something you're interested in working on?

Sorry, I got caught up in some personal work. I will not be able to continue on this for sometime. Please feel free to take this forward. Again sorry for not updating the thread.

@williammartin
Copy link
Member

Absolutely no problem @rajhawaldar, totally understand. I'm going to close this and then anyone else who would like to pick it up can, or you can open it up again in the future. Thanks for your efforts regardless!

@Bobstar55

This comment was marked as spam.

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.

Show host name in repo creation prompts

5 participants