Skip to content

Commit e7e3a4f

Browse files
author
Daniel Foad
committed
pr comments
1 parent 09157f1 commit e7e3a4f

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

command/pr.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,17 @@ func prStatus(cmd *cobra.Command, args []string) error {
7373
return err
7474
}
7575

76-
remotes, err := ctx.Remotes()
77-
if err != nil {
78-
return err
79-
}
80-
8176
currentUser, err := ctx.AuthLogin()
8277
if err != nil {
8378
return err
8479
}
8580

86-
repoOverride, _ := cmd.Flags().GetString("repo")
87-
88-
remoteContext, err := context.ResolveRemotesToRepos(remotes, apiClient, repoOverride)
89-
if err != nil {
90-
return err
91-
}
92-
9381
baseRepo, err := determineBaseRepo(cmd, ctx)
9482
if err != nil {
9583
return err
9684
}
9785

86+
repoOverride, _ := cmd.Flags().GetString("repo")
9887
currentPRNumber, currentPRHeadRef, err := prSelectorForCurrentBranch(ctx, baseRepo)
9988
if err != nil && repoOverride == "" && err.Error() != "git: not on any branch" {
10089
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 {
114103
printHeader(out, "Current branch")
115104
currentPR := prPayload.CurrentPR
116105
currentBranch, _ := ctx.Branch()
117-
remoteRepo, _ := remoteContext.BaseRepo()
118106
noPRMessage := fmt.Sprintf(" There is no pull request associated with %s", utils.Cyan("["+currentPRHeadRef+"]"))
119107
if currentPR != nil {
120-
if remoteRepo.DefaultBranchRef.Name == currentBranch && currentPR.State != "OPEN" {
108+
if baseRepo.(*api.Repository).DefaultBranchRef.Name == currentBranch && currentPR.State != "OPEN" {
121109
printMessage(out, noPRMessage)
122110
} else {
123111
printPrs(out, 0, *currentPR)

command/pr_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func TestPRStatus(t *testing.T) {
7777
initBlankContext("", "OWNER/REPO", "blueberries")
7878
http := initFakeHTTP()
7979
http.StubRepoResponse("OWNER", "REPO")
80-
http.StubRepoResponse("OWNER", "REPO")
8180

8281
jsonFile, _ := os.Open("../test/fixtures/prStatus.json")
8382
defer jsonFile.Close()
@@ -106,7 +105,6 @@ func TestPRStatus_fork(t *testing.T) {
106105
initBlankContext("", "OWNER/REPO", "blueberries")
107106
http := initFakeHTTP()
108107
http.StubForkedRepoResponse("OWNER/REPO", "PARENT/REPO")
109-
http.StubForkedRepoResponse("OWNER/REPO", "PARENT/REPO")
110108

111109
jsonFile, _ := os.Open("../test/fixtures/prStatusFork.json")
112110
defer jsonFile.Close()
@@ -137,7 +135,6 @@ func TestPRStatus_reviewsAndChecks(t *testing.T) {
137135
initBlankContext("", "OWNER/REPO", "blueberries")
138136
http := initFakeHTTP()
139137
http.StubRepoResponse("OWNER", "REPO")
140-
http.StubRepoResponse("OWNER", "REPO")
141138

142139
jsonFile, _ := os.Open("../test/fixtures/prStatusChecks.json")
143140
defer jsonFile.Close()
@@ -165,7 +162,6 @@ func TestPRStatus_currentBranch_showTheMostRecentPR(t *testing.T) {
165162
initBlankContext("", "OWNER/REPO", "blueberries")
166163
http := initFakeHTTP()
167164
http.StubRepoResponse("OWNER", "REPO")
168-
http.StubRepoResponse("OWNER", "REPO")
169165

170166
jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranch.json")
171167
defer jsonFile.Close()
@@ -198,7 +194,6 @@ func TestPRStatus_currentBranch_defaultBranch(t *testing.T) {
198194
initBlankContext("", "OWNER/REPO", "blueberries")
199195
http := initFakeHTTP()
200196
http.StubRepoResponseWithDefaultBranch("OWNER", "REPO", "blueberries")
201-
http.StubRepoResponse("OWNER", "REPO")
202197

203198
jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranch.json")
204199
defer jsonFile.Close()
@@ -220,7 +215,6 @@ func TestPRStatus_currentBranch_Closed(t *testing.T) {
220215
initBlankContext("", "OWNER/REPO", "blueberries")
221216
http := initFakeHTTP()
222217
http.StubRepoResponse("OWNER", "REPO")
223-
http.StubRepoResponse("OWNER", "REPO")
224218

225219
jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchClosed.json")
226220
defer jsonFile.Close()
@@ -242,7 +236,6 @@ func TestPRStatus_currentBranch_Closed_defaultBranch(t *testing.T) {
242236
initBlankContext("", "OWNER/REPO", "blueberries")
243237
http := initFakeHTTP()
244238
http.StubRepoResponseWithDefaultBranch("OWNER", "REPO", "blueberries")
245-
http.StubRepoResponse("OWNER", "REPO")
246239

247240
jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchClosed.json")
248241
defer jsonFile.Close()
@@ -264,7 +257,6 @@ func TestPRStatus_currentBranch_Merged(t *testing.T) {
264257
initBlankContext("", "OWNER/REPO", "blueberries")
265258
http := initFakeHTTP()
266259
http.StubRepoResponse("OWNER", "REPO")
267-
http.StubRepoResponse("OWNER", "REPO")
268260

269261
jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchMerged.json")
270262
defer jsonFile.Close()
@@ -286,7 +278,6 @@ func TestPRStatus_currentBranch_Merged_defaultBranch(t *testing.T) {
286278
initBlankContext("", "OWNER/REPO", "blueberries")
287279
http := initFakeHTTP()
288280
http.StubRepoResponseWithDefaultBranch("OWNER", "REPO", "blueberries")
289-
http.StubRepoResponse("OWNER", "REPO")
290281

291282
jsonFile, _ := os.Open("../test/fixtures/prStatusCurrentBranchMerged.json")
292283
defer jsonFile.Close()
@@ -308,7 +299,6 @@ func TestPRStatus_blankSlate(t *testing.T) {
308299
initBlankContext("", "OWNER/REPO", "blueberries")
309300
http := initFakeHTTP()
310301
http.StubRepoResponse("OWNER", "REPO")
311-
http.StubRepoResponse("OWNER", "REPO")
312302

313303
http.StubResponse(200, bytes.NewBufferString(`
314304
{ "data": {} }

0 commit comments

Comments
 (0)