MCPcopy Create free account
hub / github.com/github/gh-aw / evalCreatePullRequest

Function evalCreatePullRequest

pkg/cli/outcome_eval_pr.go:49–129  ·  view source on GitHub ↗

evalCreatePullRequest checks whether a PR was merged, closed, or is still open.

(item CreatedItemReport, repoOverride string)

Source from the content-addressed store, hash-verified

47
48// evalCreatePullRequest checks whether a PR was merged, closed, or is still open.
49func 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)

Callers

nothing calls this directly

Calls 9

resolveItemRepoFunction · 0.85
resolveItemNumberFunction · 0.85
findPRByTimestampFunction · 0.85
ghAPIGetFunction · 0.85
timeBetweenFunction · 0.85
ghAPIGetArrayFunction · 0.85
isBotUserFunction · 0.85
PrintfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected