diff --git a/internal/codespaces/api/api_test.go b/internal/codespaces/api/api_test.go index 65852cc79..722657197 100644 --- a/internal/codespaces/api/api_test.go +++ b/internal/codespaces/api/api_test.go @@ -565,7 +565,7 @@ func TestRetries(t *testing.T) { t.Fatalf("expected codespace name to be %q but got %q", csName, cs.Name) } callCount = 0 - handler = func(w http.ResponseWriter, r *http.Request) { + handler = func(w http.ResponseWriter, _ *http.Request) { callCount++ err := json.NewEncoder(w).Encode(Codespace{ Name: csName, @@ -755,7 +755,7 @@ func TestAPI_EditCodespace(t *testing.T) { } } -func createFakeEditPendingOpServer(t *testing.T) *httptest.Server { +func createFakeEditPendingOpServer() *httptest.Server { return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method == http.MethodPatch { w.WriteHeader(http.StatusUnprocessableEntity) @@ -776,7 +776,7 @@ func createFakeEditPendingOpServer(t *testing.T) *httptest.Server { } func TestAPI_EditCodespacePendingOperation(t *testing.T) { - svr := createFakeEditPendingOpServer(t) + svr := createFakeEditPendingOpServer() defer svr.Close() a := &API{ diff --git a/pkg/cmd/auth/setupgit/setupgit_test.go b/pkg/cmd/auth/setupgit/setupgit_test.go index 01da33543..c1982f553 100644 --- a/pkg/cmd/auth/setupgit/setupgit_test.go +++ b/pkg/cmd/auth/setupgit/setupgit_test.go @@ -203,6 +203,6 @@ func Test_setupGitRun(t *testing.T) { func login(t *testing.T, c config.Config, hostname, username, token, gitProtocol string, secureStorage bool) { t.Helper() - _, err := c.Authentication().Login(hostname, username, token, "https", secureStorage) + _, err := c.Authentication().Login(hostname, username, token, gitProtocol, secureStorage) require.NoError(t, err) } diff --git a/pkg/cmd/auth/token/token_test.go b/pkg/cmd/auth/token/token_test.go index 6e9e246af..995653fd1 100644 --- a/pkg/cmd/auth/token/token_test.go +++ b/pkg/cmd/auth/token/token_test.go @@ -274,6 +274,6 @@ func TestTokenRunSecureStorage(t *testing.T) { func login(t *testing.T, c config.Config, hostname, username, token, gitProtocol string, secureStorage bool) { t.Helper() - _, err := c.Authentication().Login(hostname, username, token, "https", secureStorage) + _, err := c.Authentication().Login(hostname, username, token, gitProtocol, secureStorage) require.NoError(t, err) } diff --git a/pkg/cmd/issue/lock/lock.go b/pkg/cmd/issue/lock/lock.go index 2cfe3880d..d33040798 100644 --- a/pkg/cmd/issue/lock/lock.go +++ b/pkg/cmd/issue/lock/lock.go @@ -103,7 +103,7 @@ type LockOptions struct { Interactive bool } -func (opts *LockOptions) setCommonOptions(f *cmdutil.Factory, cmd *cobra.Command, args []string) { +func (opts *LockOptions) setCommonOptions(f *cmdutil.Factory, args []string) { opts.IO = f.IOStreams opts.HttpClient = f.HttpClient opts.Config = f.Config @@ -129,7 +129,7 @@ func NewCmdLock(f *cmdutil.Factory, parentName string, runF func(string, *LockOp Short: short, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - opts.setCommonOptions(f, cmd, args) + opts.setCommonOptions(f, args) reasonProvided := cmd.Flags().Changed("reason") if reasonProvided { @@ -172,7 +172,7 @@ func NewCmdUnlock(f *cmdutil.Factory, parentName string, runF func(string, *Lock Short: short, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - opts.setCommonOptions(f, cmd, args) + opts.setCommonOptions(f, args) if runF != nil { return runF(Unlock, opts) @@ -261,7 +261,7 @@ func lockRun(state string, opts *LockOptions) error { case Unlock: if issuePr.Locked { - err = unlockLockable(httpClient, baseRepo, issuePr, opts) + err = unlockLockable(httpClient, baseRepo, issuePr) } else { successMsg = fmt.Sprintf("%s %s#%d already unlocked. Nothing changed.\n", parent.FullName, ghrepo.FullName(baseRepo), issuePr.Number) @@ -303,7 +303,7 @@ func lockLockable(httpClient *http.Client, repo ghrepo.Interface, lockable *api. } // unlockLockable will unlock an issue or pull request -func unlockLockable(httpClient *http.Client, repo ghrepo.Interface, lockable *api.Issue, opts *LockOptions) error { +func unlockLockable(httpClient *http.Client, repo ghrepo.Interface, lockable *api.Issue) error { var mutation struct { UnlockLockable struct { @@ -344,7 +344,7 @@ func relockLockable(httpClient *http.Client, repo ghrepo.Interface, lockable *ap return relocked, nil } - err = unlockLockable(httpClient, repo, lockable, opts) + err = unlockLockable(httpClient, repo, lockable) if err != nil { return relocked, err } diff --git a/pkg/cmd/pr/edit/edit_test.go b/pkg/cmd/pr/edit/edit_test.go index 1f422f9a8..0986797ea 100644 --- a/pkg/cmd/pr/edit/edit_test.go +++ b/pkg/cmd/pr/edit/edit_test.go @@ -305,7 +305,7 @@ func Test_editRun(t *testing.T) { tests := []struct { name string input *EditOptions - httpStubs func(*testing.T, *httpmock.Registry) + httpStubs func(*httpmock.Registry) stdout string stderr string }{ @@ -359,12 +359,12 @@ func Test_editRun(t *testing.T) { }, Fetcher: testFetcher{}, }, - httpStubs: func(t *testing.T, reg *httpmock.Registry) { - mockRepoMetadata(t, reg, false) - mockPullRequestUpdate(t, reg) - mockPullRequestReviewersUpdate(t, reg) - mockPullRequestUpdateLabels(t, reg) - mockProjectV2ItemUpdate(t, reg) + httpStubs: func(reg *httpmock.Registry) { + mockRepoMetadata(reg, false) + mockPullRequestUpdate(reg) + mockPullRequestReviewersUpdate(reg) + mockPullRequestUpdateLabels(reg) + mockProjectV2ItemUpdate(reg) }, stdout: "https://github.com/OWNER/REPO/pull/123\n", }, @@ -413,11 +413,11 @@ func Test_editRun(t *testing.T) { }, Fetcher: testFetcher{}, }, - httpStubs: func(t *testing.T, reg *httpmock.Registry) { - mockRepoMetadata(t, reg, true) - mockPullRequestUpdate(t, reg) - mockPullRequestUpdateLabels(t, reg) - mockProjectV2ItemUpdate(t, reg) + httpStubs: func(reg *httpmock.Registry) { + mockRepoMetadata(reg, true) + mockPullRequestUpdate(reg) + mockPullRequestUpdateLabels(reg) + mockProjectV2ItemUpdate(reg) }, stdout: "https://github.com/OWNER/REPO/pull/123\n", }, @@ -433,12 +433,12 @@ func Test_editRun(t *testing.T) { Fetcher: testFetcher{}, EditorRetriever: testEditorRetriever{}, }, - httpStubs: func(t *testing.T, reg *httpmock.Registry) { - mockRepoMetadata(t, reg, false) - mockPullRequestUpdate(t, reg) - mockPullRequestReviewersUpdate(t, reg) - mockPullRequestUpdateLabels(t, reg) - mockProjectV2ItemUpdate(t, reg) + httpStubs: func(reg *httpmock.Registry) { + mockRepoMetadata(reg, false) + mockPullRequestUpdate(reg) + mockPullRequestReviewersUpdate(reg) + mockPullRequestUpdateLabels(reg) + mockProjectV2ItemUpdate(reg) }, stdout: "https://github.com/OWNER/REPO/pull/123\n", }, @@ -454,11 +454,11 @@ func Test_editRun(t *testing.T) { Fetcher: testFetcher{}, EditorRetriever: testEditorRetriever{}, }, - httpStubs: func(t *testing.T, reg *httpmock.Registry) { - mockRepoMetadata(t, reg, true) - mockPullRequestUpdate(t, reg) - mockPullRequestUpdateLabels(t, reg) - mockProjectV2ItemUpdate(t, reg) + httpStubs: func(reg *httpmock.Registry) { + mockRepoMetadata(reg, true) + mockPullRequestUpdate(reg) + mockPullRequestUpdateLabels(reg) + mockProjectV2ItemUpdate(reg) }, stdout: "https://github.com/OWNER/REPO/pull/123\n", }, @@ -472,7 +472,7 @@ func Test_editRun(t *testing.T) { reg := &httpmock.Registry{} defer reg.Verify(t) - tt.httpStubs(t, reg) + tt.httpStubs(reg) httpClient := func() (*http.Client, error) { return &http.Client{Transport: reg}, nil } @@ -487,7 +487,7 @@ func Test_editRun(t *testing.T) { } } -func mockRepoMetadata(_ *testing.T, reg *httpmock.Registry, skipReviewers bool) { +func mockRepoMetadata(reg *httpmock.Registry, skipReviewers bool) { reg.Register( httpmock.GraphQL(`query RepositoryAssignableUsers\b`), httpmock.StringResponse(` @@ -595,19 +595,19 @@ func mockRepoMetadata(_ *testing.T, reg *httpmock.Registry, skipReviewers bool) } } -func mockPullRequestUpdate(t *testing.T, reg *httpmock.Registry) { +func mockPullRequestUpdate(reg *httpmock.Registry) { reg.Register( httpmock.GraphQL(`mutation PullRequestUpdate\b`), httpmock.StringResponse(`{}`)) } -func mockPullRequestReviewersUpdate(t *testing.T, reg *httpmock.Registry) { +func mockPullRequestReviewersUpdate(reg *httpmock.Registry) { reg.Register( httpmock.GraphQL(`mutation PullRequestUpdateRequestReviews\b`), httpmock.StringResponse(`{}`)) } -func mockPullRequestUpdateLabels(t *testing.T, reg *httpmock.Registry) { +func mockPullRequestUpdateLabels(reg *httpmock.Registry) { reg.Register( httpmock.GraphQL(`mutation LabelAdd\b`), httpmock.GraphQLMutation(` @@ -622,7 +622,7 @@ func mockPullRequestUpdateLabels(t *testing.T, reg *httpmock.Registry) { ) } -func mockProjectV2ItemUpdate(t *testing.T, reg *httpmock.Registry) { +func mockProjectV2ItemUpdate(reg *httpmock.Registry) { reg.Register( httpmock.GraphQL(`mutation UpdateProjectV2Items\b`), httpmock.GraphQLMutation(` diff --git a/pkg/cmd/pr/review/review.go b/pkg/cmd/pr/review/review.go index 3420d999a..b1cc500c2 100644 --- a/pkg/cmd/pr/review/review.go +++ b/pkg/cmd/pr/review/review.go @@ -157,15 +157,11 @@ func reviewRun(opts *ReviewOptions) error { var reviewData *api.PullRequestReviewInput if opts.InteractiveMode { - editorCommand, err := cmdutil.DetermineEditor(opts.Config) + reviewData, err = reviewSurvey(opts) if err != nil { return err } - reviewData, err = reviewSurvey(opts, editorCommand) - if err != nil { - return err - } - if reviewData == nil && err == nil { + if reviewData == nil { fmt.Fprint(opts.IO.ErrOut, "Discarding.\n") return nil } @@ -205,7 +201,7 @@ func reviewRun(opts *ReviewOptions) error { return nil } -func reviewSurvey(opts *ReviewOptions, editorCommand string) (*api.PullRequestReviewInput, error) { +func reviewSurvey(opts *ReviewOptions) (*api.PullRequestReviewInput, error) { options := []string{"Comment", "Approve", "Request Changes"} reviewType, err := opts.Prompter.Select( "What kind of review do you want to give?", diff --git a/pkg/cmd/pr/review/review_test.go b/pkg/cmd/pr/review/review_test.go index 0d599167c..b27eb4f8a 100644 --- a/pkg/cmd/pr/review/review_test.go +++ b/pkg/cmd/pr/review/review_test.go @@ -11,7 +11,6 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/cli/cli/v2/api" - "github.com/cli/cli/v2/context" "github.com/cli/cli/v2/internal/config" "github.com/cli/cli/v2/internal/ghrepo" "github.com/cli/cli/v2/internal/prompter" @@ -166,7 +165,7 @@ func Test_NewCmdReview(t *testing.T) { } } -func runCommand(rt http.RoundTripper, prompter prompter.Prompter, remotes context.Remotes, isTTY bool, cli string) (*test.CmdOut, error) { +func runCommand(rt http.RoundTripper, prompter prompter.Prompter, isTTY bool, cli string) (*test.CmdOut, error) { ios, _, stdout, stderr := iostreams.Test() ios.SetStdoutTTY(isTTY) ios.SetStdinTTY(isTTY) @@ -249,7 +248,7 @@ func TestPRReview(t *testing.T) { }), ) - output, err := runCommand(http, nil, nil, false, tt.args) + output, err := runCommand(http, nil, false, tt.args) assert.NoError(t, err) assert.Equal(t, "", output.String()) assert.Equal(t, "", output.Stderr()) @@ -278,13 +277,13 @@ func TestPRReview_interactive(t *testing.T) { ConfirmFunc: func(_ string, _ bool) (bool, error) { return true, nil }, } - output, err := runCommand(http, pm, nil, true, "") + output, err := runCommand(http, pm, true, "") assert.NoError(t, err) assert.Equal(t, heredoc.Doc(` Got: cool story - + `), output.String()) assert.Equal(t, "✓ Approved pull request OWNER/REPO#123\n", output.Stderr()) } @@ -300,7 +299,7 @@ func TestPRReview_interactive_no_body(t *testing.T) { MarkdownEditorFunc: func(_, _ string, _ bool) (string, error) { return "", nil }, } - _, err := runCommand(http, pm, nil, true, "") + _, err := runCommand(http, pm, true, "") assert.EqualError(t, err, "this type of review cannot be blank") } @@ -325,7 +324,7 @@ func TestPRReview_interactive_blank_approve(t *testing.T) { ConfirmFunc: func(_ string, _ bool) (bool, error) { return true, nil }, } - output, err := runCommand(http, pm, nil, true, "") + output, err := runCommand(http, pm, true, "") assert.NoError(t, err) assert.Equal(t, "", output.String()) assert.Equal(t, "✓ Approved pull request OWNER/REPO#123\n", output.Stderr()) diff --git a/pkg/cmd/pr/status/http.go b/pkg/cmd/pr/status/http.go index 755ccf30b..bd7eb6a78 100644 --- a/pkg/cmd/pr/status/http.go +++ b/pkg/cmd/pr/status/http.go @@ -59,7 +59,7 @@ func pullRequestStatus(httpClient *http.Client, repo ghrepo.Interface, options r fragments = fmt.Sprintf("fragment pr on PullRequest{%s}fragment prWithReviews on PullRequest{...pr}", gr) } else { var err error - fragments, err = pullRequestFragment(repo.RepoHost(), options.ConflictStatus, options.CheckRunAndStatusContextCountsSupported) + fragments, err = pullRequestFragment(options.ConflictStatus, options.CheckRunAndStatusContextCountsSupported) if err != nil { return nil, err } @@ -188,7 +188,7 @@ func pullRequestStatus(httpClient *http.Client, repo ghrepo.Interface, options r return &payload, nil } -func pullRequestFragment(hostname string, conflictStatus bool, statusCheckRollupWithCountByState bool) (string, error) { +func pullRequestFragment(conflictStatus bool, statusCheckRollupWithCountByState bool) (string, error) { fields := []string{ "number", "title", "state", "url", "isDraft", "isCrossRepository", "headRefName", "headRepositoryOwner", "mergeStateStatus",