ghListOpenPRs returns open PRs targeting the given branch via the gh CLI.
(branch string)
| 44 | // ghListOpenPRs returns open PRs targeting the given branch via |
| 45 | // the gh CLI. |
| 46 | func 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. |
no test coverage detected