fix(repo rename): strip same-owner prefix and improve prompt clarity#13036
Open
fix(repo rename): strip same-owner prefix and improve prompt clarity#13036
Conversation
The interactive prompt "Rename owner/repo to:" invites users to type the full owner/new-name form. Previously any slash in the input triggered an error about repository transfers, which is unrelated to the user's intent. - Reword prompt to "New name for owner/repo (without owner prefix):" - When the typed prefix matches the current owner, strip it and warn - When the prefix is a different owner, show an actionable error that distinguishes rename from transfer Fixes cli#13034
|
Thanks for your pull request! Unfortunately, it doesn't meet the minimum requirements for review:
Please update your PR to address the above. Requirements:
This PR will be automatically closed in 7 days if these requirements are not met. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Fix
gh repo renameowner-prefix UX confusionSummary
Fixes #13034.
When
gh repo renameprompts interactively, the prompt showsRename owner/repo to:- a formatthat naturally leads users to type
owner/new-name. The command previously rejected any namecontaining
/with an error message about repository transfers, which is unrelated to what theuser was trying to do.
This PR makes three focused changes to
pkg/cmd/repo/rename/rename.go:New name for owner/repo (without owner prefix):- removes the ambiguitybefore the user types anything.
owner/new-nameandownermatches the current repository's owner. A warning is printed to stderr so the user sees what
happened.
expected, and reserves the transfer doc link for when it's actually relevant (a different owner
was typed).
Behavior change
Same-owner prefix (new: strips and proceeds):
Different-owner prefix (new: actionable error):
Non-interactive path (
gh repo rename new-name) -unchanged.Test plan
error on different-owner prefix: verifies the new error message for a mismatched-owner input.strips same-owner prefix: verifies thatOWNER/NEW_REPOinput against anOWNER/REPOreposucceeds and calls the API with
NEW_REPO.Notes
strings.EqualFold-GitHub usernames are case-insensitive.strings.SplitN(..., 2)limits splitting to one/, so inputs likeowner/a/bproduceparts[1] = "a/b"which still contains/. This hits the same-owner-strip path, strips theprefix to
"a/b", and then the API rejects it with a server-side error - correct behavior,no special casing needed.
gh repo renamehelp text clarifies new repo name should not include owner #10044 (help text), Error whengh repo renameis used with a new repo name that contains an owner #10364 (slash validation added).