Skip to content

Commit aa0de5f

Browse files
committed
Stop using utils.Spinner in repo fork
1 parent b5366c6 commit aa0de5f

File tree

2 files changed

+2
-36
lines changed

2 files changed

+2
-36
lines changed

pkg/cmd/repo/fork/fork.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,6 @@ func forkRun(opts *ForkOptions) error {
127127

128128
cs := opts.IO.ColorScheme()
129129
stderr := opts.IO.ErrOut
130-
s := utils.Spinner(stderr)
131-
stopSpinner := func() {}
132-
133-
if connectedToTerminal {
134-
loading := cs.Gray("Forking ") + cs.Bold(cs.Gray(ghrepo.FullName(repoToFork))) + cs.Gray("...")
135-
s.Suffix = " " + loading
136-
s.FinalMSG = cs.Gray(fmt.Sprintf("- %s\n", loading))
137-
utils.StartSpinner(s)
138-
stopSpinner = func() {
139-
utils.StopSpinner(s)
140-
}
141-
}
142130

143131
httpClient, err := opts.HttpClient()
144132
if err != nil {
@@ -147,14 +135,13 @@ func forkRun(opts *ForkOptions) error {
147135

148136
apiClient := api.NewClientFromHTTP(httpClient)
149137

138+
opts.IO.StartProgressIndicator()
150139
forkedRepo, err := api.ForkRepo(apiClient, repoToFork)
140+
opts.IO.StopProgressIndicator()
151141
if err != nil {
152-
stopSpinner()
153142
return fmt.Errorf("failed to fork: %w", err)
154143
}
155144

156-
stopSpinner()
157-
158145
// This is weird. There is not an efficient way to determine via the GitHub API whether or not a
159146
// given user has forked a given repo. We noticed, also, that the create fork API endpoint just
160147
// returns the fork repo data even if it already exists -- with no change in status code or

pkg/cmd/repo/fork/fork_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/briandowns/spinner"
1312
"github.com/cli/cli/context"
1413
"github.com/cli/cli/git"
1514
"github.com/cli/cli/internal/config"
@@ -20,7 +19,6 @@ import (
2019
"github.com/cli/cli/pkg/iostreams"
2120
"github.com/cli/cli/pkg/prompt"
2221
"github.com/cli/cli/test"
23-
"github.com/cli/cli/utils"
2422
"github.com/google/shlex"
2523
"github.com/stretchr/testify/assert"
2624
)
@@ -155,7 +153,6 @@ func TestRepoFork_outside_parent_nontty(t *testing.T) {
155153
}
156154

157155
func TestRepoFork_already_forked(t *testing.T) {
158-
stubSpinner()
159156
reg := &httpmock.Registry{}
160157
defer reg.StubWithFixturePath(200, "./forkResult.json")()
161158
httpClient := &http.Client{Transport: reg}
@@ -180,7 +177,6 @@ func TestRepoFork_already_forked(t *testing.T) {
180177
}
181178

182179
func TestRepoFork_reuseRemote(t *testing.T) {
183-
stubSpinner()
184180
remotes := []*context.Remote{
185181
{
186182
Remote: &git.Remote{Name: "origin", FetchURL: &url.URL{}},
@@ -208,7 +204,6 @@ func TestRepoFork_reuseRemote(t *testing.T) {
208204
}
209205

210206
func TestRepoFork_in_parent(t *testing.T) {
211-
stubSpinner()
212207
reg := &httpmock.Registry{}
213208
defer reg.StubWithFixturePath(200, "./forkResult.json")()
214209
httpClient := &http.Client{Transport: reg}
@@ -234,7 +229,6 @@ func TestRepoFork_in_parent(t *testing.T) {
234229
}
235230

236231
func TestRepoFork_outside(t *testing.T) {
237-
stubSpinner()
238232
tests := []struct {
239233
name string
240234
args string
@@ -273,7 +267,6 @@ func TestRepoFork_outside(t *testing.T) {
273267
}
274268

275269
func TestRepoFork_in_parent_yes(t *testing.T) {
276-
stubSpinner()
277270
defer stubSince(2 * time.Second)()
278271
reg := &httpmock.Registry{}
279272
defer reg.StubWithFixturePath(200, "./forkResult.json")()
@@ -308,7 +301,6 @@ func TestRepoFork_in_parent_yes(t *testing.T) {
308301
}
309302

310303
func TestRepoFork_outside_yes(t *testing.T) {
311-
stubSpinner()
312304
defer stubSince(2 * time.Second)()
313305
reg := &httpmock.Registry{}
314306
defer reg.StubWithFixturePath(200, "./forkResult.json")()
@@ -337,7 +329,6 @@ func TestRepoFork_outside_yes(t *testing.T) {
337329
}
338330

339331
func TestRepoFork_outside_survey_yes(t *testing.T) {
340-
stubSpinner()
341332
defer stubSince(2 * time.Second)()
342333
reg := &httpmock.Registry{}
343334
defer reg.StubWithFixturePath(200, "./forkResult.json")()
@@ -368,7 +359,6 @@ func TestRepoFork_outside_survey_yes(t *testing.T) {
368359
}
369360

370361
func TestRepoFork_outside_survey_no(t *testing.T) {
371-
stubSpinner()
372362
defer stubSince(2 * time.Second)()
373363
reg := &httpmock.Registry{}
374364
defer reg.StubWithFixturePath(200, "./forkResult.json")()
@@ -400,7 +390,6 @@ func TestRepoFork_outside_survey_no(t *testing.T) {
400390
}
401391

402392
func TestRepoFork_in_parent_survey_yes(t *testing.T) {
403-
stubSpinner()
404393
reg := &httpmock.Registry{}
405394
defer reg.StubWithFixturePath(200, "./forkResult.json")()
406395
httpClient := &http.Client{Transport: reg}
@@ -438,7 +427,6 @@ func TestRepoFork_in_parent_survey_yes(t *testing.T) {
438427
}
439428

440429
func TestRepoFork_in_parent_survey_no(t *testing.T) {
441-
stubSpinner()
442430
reg := &httpmock.Registry{}
443431
defer reg.StubWithFixturePath(200, "./forkResult.json")()
444432
httpClient := &http.Client{Transport: reg}
@@ -470,7 +458,6 @@ func TestRepoFork_in_parent_survey_no(t *testing.T) {
470458
}
471459

472460
func TestRepoFork_in_parent_match_protocol(t *testing.T) {
473-
stubSpinner()
474461
defer stubSince(2 * time.Second)()
475462
reg := &httpmock.Registry{}
476463
defer reg.StubWithFixturePath(200, "./forkResult.json")()
@@ -513,14 +500,6 @@ func TestRepoFork_in_parent_match_protocol(t *testing.T) {
513500
reg.Verify(t)
514501
}
515502

516-
func stubSpinner() {
517-
// not bothering with teardown since we never want spinners when doing tests
518-
utils.StartSpinner = func(_ *spinner.Spinner) {
519-
}
520-
utils.StopSpinner = func(_ *spinner.Spinner) {
521-
}
522-
}
523-
524503
func stubSince(d time.Duration) func() {
525504
originalSince := Since
526505
Since = func(t time.Time) time.Duration {

0 commit comments

Comments
 (0)