diff --git a/pkg/cmd/repo/fork/fork.go b/pkg/cmd/repo/fork/fork.go index 760bb6537..322e08173 100644 --- a/pkg/cmd/repo/fork/fork.go +++ b/pkg/cmd/repo/fork/fork.go @@ -127,18 +127,6 @@ func forkRun(opts *ForkOptions) error { cs := opts.IO.ColorScheme() stderr := opts.IO.ErrOut - s := utils.Spinner(stderr) - stopSpinner := func() {} - - if connectedToTerminal { - loading := cs.Gray("Forking ") + cs.Bold(cs.Gray(ghrepo.FullName(repoToFork))) + cs.Gray("...") - s.Suffix = " " + loading - s.FinalMSG = cs.Gray(fmt.Sprintf("- %s\n", loading)) - utils.StartSpinner(s) - stopSpinner = func() { - utils.StopSpinner(s) - } - } httpClient, err := opts.HttpClient() if err != nil { @@ -147,14 +135,13 @@ func forkRun(opts *ForkOptions) error { apiClient := api.NewClientFromHTTP(httpClient) + opts.IO.StartProgressIndicator() forkedRepo, err := api.ForkRepo(apiClient, repoToFork) + opts.IO.StopProgressIndicator() if err != nil { - stopSpinner() return fmt.Errorf("failed to fork: %w", err) } - stopSpinner() - // This is weird. There is not an efficient way to determine via the GitHub API whether or not a // given user has forked a given repo. We noticed, also, that the create fork API endpoint just // returns the fork repo data even if it already exists -- with no change in status code or diff --git a/pkg/cmd/repo/fork/fork_test.go b/pkg/cmd/repo/fork/fork_test.go index 20f396394..93c73d740 100644 --- a/pkg/cmd/repo/fork/fork_test.go +++ b/pkg/cmd/repo/fork/fork_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/briandowns/spinner" "github.com/cli/cli/context" "github.com/cli/cli/git" "github.com/cli/cli/internal/config" @@ -20,7 +19,6 @@ import ( "github.com/cli/cli/pkg/iostreams" "github.com/cli/cli/pkg/prompt" "github.com/cli/cli/test" - "github.com/cli/cli/utils" "github.com/google/shlex" "github.com/stretchr/testify/assert" ) @@ -155,7 +153,6 @@ func TestRepoFork_outside_parent_nontty(t *testing.T) { } func TestRepoFork_already_forked(t *testing.T) { - stubSpinner() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() httpClient := &http.Client{Transport: reg} @@ -180,7 +177,6 @@ func TestRepoFork_already_forked(t *testing.T) { } func TestRepoFork_reuseRemote(t *testing.T) { - stubSpinner() remotes := []*context.Remote{ { Remote: &git.Remote{Name: "origin", FetchURL: &url.URL{}}, @@ -208,7 +204,6 @@ func TestRepoFork_reuseRemote(t *testing.T) { } func TestRepoFork_in_parent(t *testing.T) { - stubSpinner() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() httpClient := &http.Client{Transport: reg} @@ -234,7 +229,6 @@ func TestRepoFork_in_parent(t *testing.T) { } func TestRepoFork_outside(t *testing.T) { - stubSpinner() tests := []struct { name string args string @@ -273,7 +267,6 @@ func TestRepoFork_outside(t *testing.T) { } func TestRepoFork_in_parent_yes(t *testing.T) { - stubSpinner() defer stubSince(2 * time.Second)() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() @@ -308,7 +301,6 @@ func TestRepoFork_in_parent_yes(t *testing.T) { } func TestRepoFork_outside_yes(t *testing.T) { - stubSpinner() defer stubSince(2 * time.Second)() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() @@ -337,7 +329,6 @@ func TestRepoFork_outside_yes(t *testing.T) { } func TestRepoFork_outside_survey_yes(t *testing.T) { - stubSpinner() defer stubSince(2 * time.Second)() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() @@ -368,7 +359,6 @@ func TestRepoFork_outside_survey_yes(t *testing.T) { } func TestRepoFork_outside_survey_no(t *testing.T) { - stubSpinner() defer stubSince(2 * time.Second)() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() @@ -400,7 +390,6 @@ func TestRepoFork_outside_survey_no(t *testing.T) { } func TestRepoFork_in_parent_survey_yes(t *testing.T) { - stubSpinner() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() httpClient := &http.Client{Transport: reg} @@ -438,7 +427,6 @@ func TestRepoFork_in_parent_survey_yes(t *testing.T) { } func TestRepoFork_in_parent_survey_no(t *testing.T) { - stubSpinner() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() httpClient := &http.Client{Transport: reg} @@ -470,7 +458,6 @@ func TestRepoFork_in_parent_survey_no(t *testing.T) { } func TestRepoFork_in_parent_match_protocol(t *testing.T) { - stubSpinner() defer stubSince(2 * time.Second)() reg := &httpmock.Registry{} defer reg.StubWithFixturePath(200, "./forkResult.json")() @@ -513,14 +500,6 @@ func TestRepoFork_in_parent_match_protocol(t *testing.T) { reg.Verify(t) } -func stubSpinner() { - // not bothering with teardown since we never want spinners when doing tests - utils.StartSpinner = func(_ *spinner.Spinner) { - } - utils.StopSpinner = func(_ *spinner.Spinner) { - } -} - func stubSince(d time.Duration) func() { originalSince := Since Since = func(t time.Time) time.Duration {