Skip to content

gh repo rename always sets github.com for new origin URLs, doesn't support other github instance URLs #7862

@matefriedl

Description

@matefriedl

Describe the bug

I am using the cli with our internal github enterprise instance. When renaming a repository with the gh repo rename command, the origin's URL is set incorrectly. Regardless of my enterprise URL, it is always set as if I was using github.com

 # gh --version
gh version 2.23.0 (2023-02-08)
https://github.com/cli/cli/releases/tag/v2.23.0

Steps to reproduce the behavior

  1. Make sure that you are only authenticated with a github enterprise URL (or anything that isn't github.com)
  2. Attempt to rename a repository
  3. Observe that the origin's url is not set correctly

Expected vs actual behavior

the new origin URL is set to git@github.com:username/newreponame instead of git@github.mycompany.com:username/newreponame

Logs

$ gh auth status
github.mycompany.com
  ✓ Logged in to github.mycompany.com as matefriedl
  ✓ Git operations for github.mycompany.com configured to use ssh protocol.
  ✓ Token: gho_************************************
  ✓ Token scopes: admin:public_key, gist, read:org, repo
$ gh repo create gh-rename-bug-repro -c --public
✓ Created repository matefriedl/gh-rename-bug-repro on GitHub
$ cd .\gh-rename-bug-repro\
$ git remote -v
origin  git@github.mycompany.com:matefriedl/gh-rename-bug-repro.git (fetch)
origin  git@github.mycompany.com:matefriedl/gh-rename-bug-repro.git (push)
$ gh repo rename newreponame
?  Rename matefriedl/gh-rename-bug-repro to newreponame? Yes
✓ Renamed repository matefriedl/newreponamenewreponame? (y/N) y
✓ Updated the "origin" remote
$ git remote -v
origin  git@github.com:matefriedl/newreponame.git (fetch)
origin  git@github.com:matefriedl/newreponame.git (push)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions