diff --git a/command/pr.go b/command/pr.go index 3e7f0ccb2..22f083b97 100644 --- a/command/pr.go +++ b/command/pr.go @@ -73,28 +73,17 @@ func prStatus(cmd *cobra.Command, args []string) error { return err } - remotes, err := ctx.Remotes() - if err != nil { - return err - } - currentUser, err := ctx.AuthLogin() if err != nil { return err } - repoOverride, _ := cmd.Flags().GetString("repo") - - remoteContext, err := context.ResolveRemotesToRepos(remotes, apiClient, repoOverride) - if err != nil { - return err - } - baseRepo, err := determineBaseRepo(cmd, ctx) if err != nil { return err } + repoOverride, _ := cmd.Flags().GetString("repo") currentPRNumber, currentPRHeadRef, err := prSelectorForCurrentBranch(ctx, baseRepo) if err != nil && repoOverride == "" && err.Error() != "git: not on any branch" { return fmt.Errorf("could not query for pull request for current branch: %w", err) @@ -114,10 +103,9 @@ func prStatus(cmd *cobra.Command, args []string) error { printHeader(out, "Current branch") currentPR := prPayload.CurrentPR currentBranch, _ := ctx.Branch() - remoteRepo, _ := remoteContext.BaseRepo() noPRMessage := fmt.Sprintf(" There is no pull request associated with %s", utils.Cyan("["+currentPRHeadRef+"]")) if currentPR != nil { - if remoteRepo.DefaultBranchRef.Name == currentBranch && currentPR.State != "OPEN" { + if baseRepo.(*api.Repository).DefaultBranchRef.Name == currentBranch && currentPR.State != "OPEN" { printMessage(out, noPRMessage) } else { printPrs(out, 0, *currentPR) diff --git a/command/pr_test.go b/command/pr_test.go index 950c4af9e..aa4633541 100644 --- a/command/pr_test.go +++ b/command/pr_test.go @@ -77,7 +77,6 @@ func TestPRStatus(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponse("OWNER", "REPO") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatus.json") defer jsonFile.Close() @@ -106,7 +105,6 @@ func TestPRStatus_fork(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubForkedRepoResponse("OWNER/REPO", "PARENT/REPO") - http.StubForkedRepoResponse("OWNER/REPO", "PARENT/REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusFork.json") defer jsonFile.Close() @@ -137,7 +135,6 @@ func TestPRStatus_reviewsAndChecks(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponse("OWNER", "REPO") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusChecks.json") defer jsonFile.Close() @@ -165,7 +162,6 @@ func TestPRStatus_currentBranch_showTheMostRecentPR(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponse("OWNER", "REPO") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranch.json") defer jsonFile.Close() @@ -198,7 +194,6 @@ func TestPRStatus_currentBranch_defaultBranch(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponseWithDefaultBranch("OWNER", "REPO", "blueberries") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranch.json") defer jsonFile.Close() @@ -220,7 +215,6 @@ func TestPRStatus_currentBranch_Closed(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponse("OWNER", "REPO") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchClosed.json") defer jsonFile.Close() @@ -242,7 +236,6 @@ func TestPRStatus_currentBranch_Closed_defaultBranch(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponseWithDefaultBranch("OWNER", "REPO", "blueberries") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchClosed.json") defer jsonFile.Close() @@ -264,7 +257,6 @@ func TestPRStatus_currentBranch_Merged(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponse("OWNER", "REPO") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchMerged.json") defer jsonFile.Close() @@ -286,7 +278,6 @@ func TestPRStatus_currentBranch_Merged_defaultBranch(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponseWithDefaultBranch("OWNER", "REPO", "blueberries") - http.StubRepoResponse("OWNER", "REPO") jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchMerged.json") defer jsonFile.Close() @@ -308,7 +299,6 @@ func TestPRStatus_blankSlate(t *testing.T) { initBlankContext("", "OWNER/REPO", "blueberries") http := initFakeHTTP() http.StubRepoResponse("OWNER", "REPO") - http.StubRepoResponse("OWNER", "REPO") http.StubResponse(200, bytes.NewBufferString(` { "data": {} }