Merge pull request #10158 from aryanbhosale/trunk

fix(repo fork): add non-TTY output when fork is newly created
This commit is contained in:
Tyler McGoffin 2025-01-06 10:11:14 -08:00 committed by GitHub
commit 1f4e005562
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -221,6 +221,8 @@ func forkRun(opts *ForkOptions) error {
} else {
if connectedToTerminal {
fmt.Fprintf(stderr, "%s Created fork %s\n", cs.SuccessIconWithColor(cs.Green), cs.Bold(ghrepo.FullName(forkedRepo)))
} else {
fmt.Fprintln(opts.IO.Out, ghrepo.GenerateRepoURL(forkedRepo, ""))
}
}

View file

@ -390,6 +390,7 @@ func TestRepoFork(t *testing.T) {
},
},
httpStubs: forkPost,
wantOut: "https://github.com/someone/REPO\n",
},
{
name: "implicit nontty remote exists",
@ -424,11 +425,13 @@ 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, "")
},
wantOut: "https://github.com/someone/REPO\n",
},
{
name: "implicit nontty no args",
opts: &ForkOptions{},
httpStubs: forkPost,
wantOut: "https://github.com/someone/REPO\n",
},
{
name: "passes git flags",
@ -561,6 +564,7 @@ func TestRepoFork(t *testing.T) {
Repository: "OWNER/REPO",
},
httpStubs: forkPost,
wantOut: "https://github.com/someone/REPO\n",
},
{
name: "repo arg nontty repo already exists",
@ -604,6 +608,7 @@ func TestRepoFork(t *testing.T) {
cs.Register(`git -C REPO fetch upstream`, 0, "")
cs.Register(`git -C REPO config --add remote.upstream.gh-resolved base`, 0, "")
},
wantOut: "https://github.com/someone/REPO\n",
},
{
name: "non tty repo arg with fork-name",
@ -640,6 +645,7 @@ func TestRepoFork(t *testing.T) {
httpmock.StringResponse(renameResult))
},
wantErrOut: "",
wantOut: "https://github.com/OWNER/REPO\n",
},
{
name: "tty repo arg with fork-name",
@ -694,6 +700,7 @@ func TestRepoFork(t *testing.T) {
cs.Register(`git -C REPO fetch upstream`, 0, "")
cs.Register(`git -C REPO config --add remote.upstream.gh-resolved base`, 0, "")
},
wantOut: "https://github.com/someone/REPO\n",
},
{
name: "does not retry clone if error occurs and exit code is not 128",