MCPcopy Index your code
hub / github.com/coder/coder / ghListOpenPRs

Function ghListOpenPRs

scripts/releaser/github.go:46–74  ·  view source on GitHub ↗

ghListOpenPRs returns open PRs targeting the given branch via the gh CLI.

(branch string)

Source from the content-addressed store, hash-verified

44// ghListOpenPRs returns open PRs targeting the given branch via
45// the gh CLI.
46func ghListOpenPRs(branch string) ([]ghPR, error) {
47 out, err := ghOutput("pr", "list",
48 "--repo", owner+"/"+repo,
49 "--base", branch,
50 "--state", "open",
51 "--json", "number,title,author",
52 "--jq", `.[] | "\(.number)\t\(.title)\t\(.author.login)"`,
53 )
54 if err != nil {
55 return nil, err
56 }
57 if out == "" {
58 return nil, nil
59 }
60 var prs []ghPR
61 for _, line := range strings.Split(out, "\n") {
62 parts := strings.SplitN(line, "\t", 3)
63 if len(parts) < 3 {
64 continue
65 }
66 num, _ := strconv.Atoi(parts[0])
67 prs = append(prs, ghPR{
68 Number: num,
69 Title: parts[1],
70 Author: parts[2],
71 })
72 }
73 return prs, nil
74}
75
76// ghListPRsWithLabel returns merged PRs targeting the given branch
77// that have a specific label.

Callers 1

runReleaseFunction · 0.85

Calls 1

ghOutputFunction · 0.85

Tested by

no test coverage detected