Error when `gh repo rename` is used with a new repo name that contains an owner by timrogers · Pull Request #10364 · cli/cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/cmd/repo/rename/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"strings"

"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/v2/api"
Expand Down Expand Up @@ -124,6 +125,10 @@ func renameRun(opts *RenameOptions) error {
}
}

if strings.Contains(newRepoName, "/") {
return fmt.Errorf("New repository name cannot contain '/' character - to transfer a repository to a new owner, you must follow additional steps on GitHub.com. For more information on transferring repository ownership, see <https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository>.")
}

if opts.DoConfirm {
var confirmed bool
if confirmed, err = opts.Prompter.Confirm(fmt.Sprintf(
Expand Down
16 changes: 16 additions & 0 deletions pkg/cmd/repo/rename/rename_test.go