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

Function evalPushToPRBranch

pkg/cli/outcome_eval_generic.go:185–224  ·  view source on GitHub ↗

evalPushToPRBranch checks whether the PR the code was pushed to got merged.

(item CreatedItemReport, repoOverride string)

Source from the content-addressed store, hash-verified

183
184// evalPushToPRBranch checks whether the PR the code was pushed to got merged.
185func evalPushToPRBranch(item CreatedItemReport, repoOverride string) OutcomeReport {
186 repo := resolveItemRepo(item, repoOverride)
187 num := resolveItemNumber(item)
188 outcomeEvalGenericLog.Printf("Evaluating push_to_pr_branch: repo=%s, num=%d", repo, num)
189 report := OutcomeReport{
190 Type: item.Type,
191 ObjectURL: item.URL,
192 ObjectNumber: num,
193 Repo: repo,
194 }
195 if num == 0 || repo == "" {
196 report.Result = OutcomeError
197 report.EvalError = "missing PR number or repo"
198 return report
199 }
200
201 data, err := ghAPIGet(fmt.Sprintf("pulls/%d", num), repo)
202 if err != nil {
203 report.Result = OutcomeError
204 report.EvalError = err.Error()
205 return report
206 }
207
208 merged, _ := data["merged"].(bool)
209 state, _ := data["state"].(string)
210 outcomeEvalGenericLog.Printf("push_to_pr_branch PR #%d state: merged=%t, state=%s", num, merged, state)
211
212 switch {
213 case merged:
214 report.Result = OutcomeAccepted
215 report.Detail = "PR merged"
216 case state == "closed":
217 report.Result = OutcomeRejected
218 report.Detail = "PR closed without merge"
219 default:
220 report.Result = OutcomePending
221 report.Detail = "PR still open"
222 }
223 return report
224}
225
226// evalGenericSticky is a fallback evaluator for types that modify an existing object.
227// It simply checks whether the target issue/PR still exists and is accessible.

Callers

nothing calls this directly

Calls 5

resolveItemRepoFunction · 0.85
resolveItemNumberFunction · 0.85
ghAPIGetFunction · 0.85
PrintfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected