ghListPRsWithLabel returns merged PRs targeting the given branch that have a specific label.
(branch, label string)
| 76 | // ghListPRsWithLabel returns merged PRs targeting the given branch |
| 77 | // that have a specific label. |
| 78 | func ghListPRsWithLabel(branch, label string) ([]ghPR, error) { |
| 79 | out, err := ghOutput("pr", "list", |
| 80 | "--repo", owner+"/"+repo, |
| 81 | "--base", branch, |
| 82 | "--state", "merged", |
| 83 | "--label", label, |
| 84 | "--json", "number,title", |
| 85 | "--jq", `.[] | "\(.number)\t\(.title)"`, |
| 86 | ) |
| 87 | if err != nil { |
| 88 | return nil, err |
| 89 | } |
| 90 | if out == "" { |
| 91 | return nil, nil |
| 92 | } |
| 93 | var prs []ghPR |
| 94 | for _, line := range strings.Split(out, "\n") { |
| 95 | parts := strings.SplitN(line, "\t", 2) |
| 96 | if len(parts) < 2 { |
| 97 | continue |
| 98 | } |
| 99 | num, _ := strconv.Atoi(parts[0]) |
| 100 | prs = append(prs, ghPR{Number: num, Title: parts[1]}) |
| 101 | } |
| 102 | return prs, nil |
| 103 | } |
| 104 | |
| 105 | // prMetadata holds labels and author for a merged PR. |
| 106 | type prMetadata struct { |
no test coverage detected