X Tutup
Skip to content

Commit cbc2d16

Browse files
authored
Merge pull request cli#513 from cli/closed-incl-merged
Include merged PRs with `list --state=closed`
2 parents cc96ddd + 13dbfa4 commit cbc2d16

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

command/issue.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ func printIssuePreview(out io.Writer, issue *api.Issue) error {
256256
)))
257257

258258
if issue.Body != "" {
259-
fmt.Fprintln(out)
260-
md, err := utils.RenderMarkdown(issue.Body)
261-
if err != nil {
262-
return err
263-
}
264-
fmt.Fprintln(out, md)
265-
fmt.Fprintln(out)
259+
fmt.Fprintln(out)
260+
md, err := utils.RenderMarkdown(issue.Body)
261+
if err != nil {
262+
return err
263+
}
264+
fmt.Fprintln(out, md)
265+
fmt.Fprintln(out)
266266
}
267267

268268
fmt.Fprintf(out, utils.Gray("View this issue on GitHub: %s\n"), issue.URL)

command/pr.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func prList(cmd *cobra.Command, args []string) error {
163163
case "open":
164164
graphqlState = []string{"OPEN"}
165165
case "closed":
166-
graphqlState = []string{"CLOSED"}
166+
graphqlState = []string{"CLOSED", "MERGED"}
167167
case "merged":
168168
graphqlState = []string{"MERGED"}
169169
case "all":
@@ -309,12 +309,12 @@ func printPrPreview(out io.Writer, pr *api.PullRequest) error {
309309
)))
310310
if pr.Body != "" {
311311
fmt.Fprintln(out)
312-
md, err := utils.RenderMarkdown(pr.Body)
313-
if err != nil {
314-
return err
315-
}
316-
fmt.Fprintln(out, md)
317-
fmt.Fprintln(out)
312+
md, err := utils.RenderMarkdown(pr.Body)
313+
if err != nil {
314+
return err
315+
}
316+
fmt.Fprintln(out, md)
317+
fmt.Fprintln(out)
318318
}
319319

320320
fmt.Fprintf(out, utils.Gray("View this pull request on GitHub: %s\n"), pr.URL)

command/pr_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,30 @@ No pull requests match your search
210210
eq(t, reqBody.Variables.Labels, []string{"one", "two", "three"})
211211
}
212212

213+
func TestPRList_filteringClosed(t *testing.T) {
214+
initBlankContext("OWNER/REPO", "master")
215+
http := initFakeHTTP()
216+
http.StubRepoResponse("OWNER", "REPO")
217+
218+
respBody := bytes.NewBufferString(`{ "data": {} }`)
219+
http.StubResponse(200, respBody)
220+
221+
_, err := RunCommand(prListCmd, `pr list -s closed`)
222+
if err != nil {
223+
t.Fatal(err)
224+
}
225+
226+
bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body)
227+
reqBody := struct {
228+
Variables struct {
229+
State []string
230+
}
231+
}{}
232+
json.Unmarshal(bodyBytes, &reqBody)
233+
234+
eq(t, reqBody.Variables.State, []string{"CLOSED", "MERGED"})
235+
}
236+
213237
func TestPRList_filteringAssignee(t *testing.T) {
214238
initBlankContext("OWNER/REPO", "master")
215239
http := initFakeHTTP()

0 commit comments

Comments
 (0)
X Tutup