diff --git a/pkg/cmd/root/official_extension_stub.go b/pkg/cmd/root/official_extension_stub.go index 2e5a69bec..af52e4366 100644 --- a/pkg/cmd/root/official_extension_stub.go +++ b/pkg/cmd/root/official_extension_stub.go @@ -26,7 +26,7 @@ func NewCmdOfficialExtensionStub(io *iostreams.IOStreams, p prompter.Prompter, e // cobra validation errors before reaching RunE. DisableFlagParsing: true, RunE: func(cmd *cobra.Command, args []string) error { - return officialExtensionStubRun(io, p, em, ext, args) + return officialExtensionStubRun(io, p, em, ext) }, } @@ -35,7 +35,7 @@ func NewCmdOfficialExtensionStub(io *iostreams.IOStreams, p prompter.Prompter, e return cmd } -func officialExtensionStubRun(io *iostreams.IOStreams, p prompter.Prompter, em extensions.ExtensionManager, ext *extensions.OfficialExtension, args []string) error { +func officialExtensionStubRun(io *iostreams.IOStreams, p prompter.Prompter, em extensions.ExtensionManager, ext *extensions.OfficialExtension) error { stderr := io.ErrOut if !io.CanPrompt() { @@ -68,11 +68,5 @@ func officialExtensionStubRun(io *iostreams.IOStreams, p prompter.Prompter, em e } fmt.Fprintf(stderr, "Successfully installed %s/%s\n", ext.Owner, ext.Repo) - - // Dispatch the newly installed extension with the original arguments. - dispatchArgs := append([]string{ext.Name}, args...) - if _, dispatchErr := em.Dispatch(dispatchArgs, io.In, io.Out, stderr); dispatchErr != nil { - return dispatchErr - } return nil } diff --git a/pkg/cmd/root/official_extension_stub_test.go b/pkg/cmd/root/official_extension_stub_test.go index 4fadd67d3..d2fd46242 100644 --- a/pkg/cmd/root/official_extension_stub_test.go +++ b/pkg/cmd/root/official_extension_stub_test.go @@ -2,7 +2,6 @@ package root import ( "fmt" - "io" "testing" "github.com/cli/cli/v2/internal/ghrepo" @@ -17,18 +16,14 @@ func TestOfficialExtensionStubRun(t *testing.T) { ext := &extensions.OfficialExtension{Name: "cool", Owner: "github", Repo: "gh-cool"} tests := []struct { - name string - isTTY bool - confirmResult bool - confirmErr error - installErr error - dispatchErr error - args []string - wantErr string - wantStderr string - wantInstalled bool - wantDispatched bool - wantDispArgs []string + name string + isTTY bool + confirmResult bool + confirmErr error + installErr error + wantErr string + wantStderr string + wantInstalled bool }{ { name: "non-TTY prints install instructions", @@ -36,14 +31,11 @@ func TestOfficialExtensionStubRun(t *testing.T) { wantStderr: "gh extension install github/gh-cool", }, { - name: "TTY confirmed installs and dispatches", - isTTY: true, - confirmResult: true, - args: []string{"--help"}, - wantStderr: "Successfully installed github/gh-cool", - wantInstalled: true, - wantDispatched: true, - wantDispArgs: []string{"cool", "--help"}, + name: "TTY confirmed installs", + isTTY: true, + confirmResult: true, + wantStderr: "Successfully installed github/gh-cool", + wantInstalled: true, }, { name: "TTY declined does not install", @@ -64,15 +56,6 @@ func TestOfficialExtensionStubRun(t *testing.T) { wantErr: "network error", wantInstalled: true, }, - { - name: "TTY dispatch error is propagated", - isTTY: true, - confirmResult: true, - dispatchErr: fmt.Errorf("dispatch failed"), - wantErr: "dispatch failed", - wantInstalled: true, - wantDispatched: true, - }, } for _, tt := range tests { @@ -88,12 +71,6 @@ func TestOfficialExtensionStubRun(t *testing.T) { InstallFunc: func(_ ghrepo.Interface, _ string) error { return tt.installErr }, - DispatchFunc: func(_ []string, _ io.Reader, _, _ io.Writer) (bool, error) { - if tt.dispatchErr != nil { - return false, tt.dispatchErr - } - return true, nil - }, } p := &prompter.PrompterMock{ ConfirmFunc: func(_ string, _ bool) (bool, error) { @@ -101,7 +78,7 @@ func TestOfficialExtensionStubRun(t *testing.T) { }, } - err := officialExtensionStubRun(ios, p, em, ext, tt.args) + err := officialExtensionStubRun(ios, p, em, ext) if tt.wantErr != "" { require.Error(t, err) @@ -123,13 +100,6 @@ func TestOfficialExtensionStubRun(t *testing.T) { } else if tt.isTTY && !tt.confirmResult && tt.confirmErr == nil { assert.Empty(t, em.InstallCalls()) } - - if tt.wantDispatched { - require.NotEmpty(t, em.DispatchCalls()) - if tt.wantDispArgs != nil { - assert.Equal(t, tt.wantDispArgs, em.DispatchCalls()[0].Args) - } - } }) } }