-
Couldn't load subscription status.
- Fork 7.3k
fully restore fork remote renaming behavior #2982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one question. The code itself looks good to me.
pkg/cmd/repo/fork/fork.go
Outdated
| return err | ||
| } | ||
| renameTarget := "upstream" | ||
| renameCmd, err := git.GitCommand("remote", "rename", remoteName, renameTarget) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here if remoteName is blank? If remoteName is blank should we use "origin"? I think that would mimic the behavior before #1882.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the only way for remoteName to be blank is if the user passed --remote-name="", and in that case I expect that the command should fail since that isn't a valid value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was my expectation as well, but we could notice and do a nicer error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but I had one additional expectation when it comes to --remote-name, and I'm wondering what your thoughts on it would be: what if passing a --remote-name unconditionally opted out of remote renaming behavior? i.e.
gh repo fork: renames "origin" remote if it already existsgh repo fork --remote-name=foo- doesn't ever rename any existing git remotes, even if "foo" existed- corollary:
gh repo fork --remote-name=origin- doesn't ever rename the "origin" remote
- corollary:
It's a subtle difference from the current state of this PR, but I think that having a way to opt out of any magic-ness it will go a long way towards making --remote-name suitable for scripting.
pkg/cmd/repo/fork/fork.go
Outdated
| With no argument, creates a fork of the current repository. Otherwise, forks the specified repository. | ||
| By default, the new fork is set to be your 'origin' remote and any existing origin remote is renamed to 'upstream'. To alter this behavior, you can set a name for the new fork's remote with --remote-name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our help docs currently have lines hard-wrapped to 80 columns, so maybe this line should wrap too. #1469
pkg/cmd/repo/fork/fork.go
Outdated
| return err | ||
| } | ||
| renameTarget := "upstream" | ||
| renameCmd, err := git.GitCommand("remote", "rename", remoteName, renameTarget) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the only way for remoteName to be blank is if the user passed --remote-name="", and in that case I expect that the command should fail since that isn't a valid value.
|
I've:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 🎉
This fully restores the fork remote renaming behavior altered originally in #1882 but leaves the
--remote-nameflag intact; it also adds a note about this behavior to theforklongform help.Closes #2904