evalMarkReady checks whether a PR marked as ready received reviews.
(item CreatedItemReport, repoOverride string)
| 137 | |
| 138 | // evalMarkReady checks whether a PR marked as ready received reviews. |
| 139 | func evalMarkReady(item CreatedItemReport, repoOverride string) OutcomeReport { |
| 140 | repo := resolveItemRepo(item, repoOverride) |
| 141 | num := resolveItemNumber(item) |
| 142 | outcomeEvalGenericLog.Printf("Evaluating mark_ready: repo=%s, num=%d", repo, num) |
| 143 | report := OutcomeReport{ |
| 144 | Type: item.Type, |
| 145 | ObjectURL: item.URL, |
| 146 | ObjectNumber: num, |
| 147 | Repo: repo, |
| 148 | } |
| 149 | if num == 0 || repo == "" { |
| 150 | report.Result = OutcomeError |
| 151 | report.EvalError = "missing number or repo" |
| 152 | return report |
| 153 | } |
| 154 | |
| 155 | reviews, err := ghAPIGetArray(fmt.Sprintf("pulls/%d/reviews", num), repo) |
| 156 | if err != nil { |
| 157 | report.Result = OutcomeError |
| 158 | report.EvalError = err.Error() |
| 159 | return report |
| 160 | } |
| 161 | |
| 162 | if len(reviews) > 0 { |
| 163 | report.Result = OutcomeAccepted |
| 164 | report.Detail = fmt.Sprintf("%d reviews submitted", len(reviews)) |
| 165 | } else { |
| 166 | data, derr := ghAPIGet(fmt.Sprintf("pulls/%d", num), repo) |
| 167 | if derr == nil { |
| 168 | state, _ := data["state"].(string) |
| 169 | if state == "open" { |
| 170 | report.Result = OutcomePending |
| 171 | report.Detail = "awaiting review" |
| 172 | } else { |
| 173 | report.Result = OutcomeIgnored |
| 174 | report.Detail = "closed/merged without review" |
| 175 | } |
| 176 | } else { |
| 177 | report.Result = OutcomePending |
| 178 | report.Detail = "no reviews yet" |
| 179 | } |
| 180 | } |
| 181 | return report |
| 182 | } |
| 183 | |
| 184 | // evalPushToPRBranch checks whether the PR the code was pushed to got merged. |
| 185 | func evalPushToPRBranch(item CreatedItemReport, repoOverride string) OutcomeReport { |
nothing calls this directly
no test coverage detected