Skip to content

fix(repo rename): strip same-owner prefix and improve prompt clarity#13036

Open
digitalby wants to merge 1 commit intocli:trunkfrom
digitalby:feature/rename-owner-prefix-ux
Open

fix(repo rename): strip same-owner prefix and improve prompt clarity#13036
digitalby wants to merge 1 commit intocli:trunkfrom
digitalby:feature/rename-owner-prefix-ux

Conversation

@digitalby
Copy link

PR: Fix gh repo rename owner-prefix UX confusion

Summary

Fixes #13034.

When gh repo rename prompts interactively, the prompt shows Rename owner/repo to: - a format
that naturally leads users to type owner/new-name. The command previously rejected any name
containing / with an error message about repository transfers, which is unrelated to what the
user was trying to do.

This PR makes three focused changes to pkg/cmd/repo/rename/rename.go:

  • Reword the prompt to New name for owner/repo (without owner prefix): - removes the ambiguity
    before the user types anything.
  • Strip the same-owner prefix automatically when the user types owner/new-name and owner
    matches the current repository's owner. A warning is printed to stderr so the user sees what
    happened.
  • Improve the error for the different-owner case - the new message explains what format is
    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):

$ gh repo rename
New name for digitalby/poc (without owner prefix): digitalby/new-name
! Owner prefix "digitalby" stripped - renaming to "new-name"
✓ Renamed repository digitalby/new-name

Different-owner prefix (new: actionable error):

$ gh repo rename
New name for digitalby/poc (without owner prefix): otherorg/new-name
error: to rename, enter only the new repository name without an owner prefix.
To transfer this repository to a different owner, visit GitHub.com:
<https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository>

Non-interactive path (gh repo rename new-name) -unchanged.

Test plan

  • All existing tests updated to match the new prompt text - all pass.
  • error on different-owner prefix: verifies the new error message for a mismatched-owner input.
  • strips same-owner prefix: verifies that OWNER/NEW_REPO input against an OWNER/REPO repo
    succeeds and calls the API with NEW_REPO.
go test ./pkg/cmd/repo/rename/... -v

Notes

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
@digitalby digitalby requested a review from a team as a code owner March 25, 2026 16:51
@digitalby digitalby requested a review from babakks March 25, 2026 16:51
@github-actions github-actions bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed unmet-requirements and removed needs-triage needs to be reviewed labels Mar 25, 2026
@github-actions
Copy link

Thanks for your pull request! Unfortunately, it doesn't meet the minimum requirements for review:

  • None of the referenced issues have the help wanted label

Please update your PR to address the above. Requirements:

  1. Include a detailed description of what this PR does
  2. Link to an issue with the help wanted label (use Fixes #123 or Closes #123 if it resolves the issue)

This PR will be automatically closed in 7 days if these requirements are not met.

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 unmet-requirements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh repo rename: interactive prompt causes owner-prefix confusion, error message talks about transfers

1 participant