evalCreatePullRequest checks whether a PR was merged, closed, or is still open.
(item CreatedItemReport, repoOverride string)
| 47 | |
| 48 | // evalCreatePullRequest checks whether a PR was merged, closed, or is still open. |
| 49 | func evalCreatePullRequest(item CreatedItemReport, repoOverride string) OutcomeReport { |
| 50 | repo := resolveItemRepo(item, repoOverride) |
| 51 | num := resolveItemNumber(item) |
| 52 | outcomeEvalPRLog.Printf("Evaluating create_pull_request: repo=%s, num=%d, url=%s", repo, num, item.URL) |
| 53 | report := OutcomeReport{ |
| 54 | Type: item.Type, |
| 55 | ObjectURL: item.URL, |
| 56 | ObjectNumber: num, |
| 57 | Repo: repo, |
| 58 | } |
| 59 | |
| 60 | // If no PR number, try to find the PR by searching recent PRs from github-actions |
| 61 | if num == 0 && repo != "" { |
| 62 | found := findPRByTimestamp(repo, item.Timestamp) |
| 63 | if found > 0 { |
| 64 | outcomeEvalPRLog.Printf("Resolved missing PR number via timestamp search: num=%d", found) |
| 65 | num = found |
| 66 | report.ObjectNumber = num |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if num == 0 || repo == "" { |
| 71 | report.Result = OutcomeError |
| 72 | report.EvalError = "missing PR number or repo" |
| 73 | return report |
| 74 | } |
| 75 | |
| 76 | data, err := ghAPIGet(fmt.Sprintf("pulls/%d", num), repo) |
| 77 | if err != nil { |
| 78 | report.Result = OutcomeError |
| 79 | report.EvalError = err.Error() |
| 80 | return report |
| 81 | } |
| 82 | |
| 83 | merged, _ := data["merged"].(bool) |
| 84 | state, _ := data["state"].(string) |
| 85 | mergedAt, _ := data["merged_at"].(string) |
| 86 | closedAt, _ := data["closed_at"].(string) |
| 87 | |
| 88 | switch { |
| 89 | case merged: |
| 90 | report.Result = OutcomeAccepted |
| 91 | report.Detail = "merged" |
| 92 | if mergedAt != "" && item.Timestamp != "" { |
| 93 | report.TimeToOutcomeHours = timeBetween(item.Timestamp, mergedAt) |
| 94 | } |
| 95 | case state == "closed": |
| 96 | report.Result = OutcomeRejected |
| 97 | report.Detail = "closed without merge" |
| 98 | if closedAt != "" && item.Timestamp != "" { |
| 99 | report.TimeToOutcomeHours = timeBetween(item.Timestamp, closedAt) |
| 100 | } |
| 101 | default: |
| 102 | report.Result = OutcomePending |
| 103 | report.Detail = "open" |
| 104 | } |
| 105 | |
| 106 | // Count human comments (non-bot) |
nothing calls this directly
no test coverage detected