Skip to content

Commit

Permalink
Merge pull request #9983 from timrogers/timrogers/fork-rename
Browse files Browse the repository at this point in the history
When renaming an existing remote as part of remote creation in `gh repo fork`, log the change
  • Loading branch information
andyfeller authored Dec 2, 2024
2 parents 67df4a3 + c719d92 commit 5a74934
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/cmd/repo/fork/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ func forkRun(opts *ForkOptions) error {
if err != nil {
return err
}

if connectedToTerminal {
fmt.Fprintf(stderr, "%s Renamed remote %s to %s\n", cs.SuccessIcon(), cs.Bold(remoteName), cs.Bold(renameTarget))
}
} else {
return fmt.Errorf("a git remote named '%s' already exists", remoteName)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/repo/fork/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestRepoFork(t *testing.T) {
return true, nil
})
},
wantErrOut: "✓ Created fork someone/REPO\n✓ Added remote origin\n",
wantErrOut: "✓ Created fork someone/REPO\nRenamed remote origin to upstream\nAdded remote origin\n",
},
{
name: "implicit tty reuse existing remote",
Expand Down Expand Up @@ -370,7 +370,7 @@ func TestRepoFork(t *testing.T) {
cs.Register("git remote rename origin upstream", 0, "")
cs.Register(`git remote add origin https://github.com/someone/REPO.git`, 0, "")
},
wantErrOut: "✓ Created fork someone/REPO\n✓ Added remote origin\n",
wantErrOut: "✓ Created fork someone/REPO\nRenamed remote origin to upstream\nAdded remote origin\n",
},
{
name: "implicit nontty reuse existing remote",
Expand Down

0 comments on commit 5a74934

Please sign in to comment.