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

Function evalAddLabels

pkg/cli/outcome_eval_label.go:12–51  ·  view source on GitHub ↗

evalAddLabels checks whether labels added by the workflow are still present.

(item CreatedItemReport, repoOverride string)

Source from the content-addressed store, hash-verified

10
11// evalAddLabels checks whether labels added by the workflow are still present.
12func evalAddLabels(item CreatedItemReport, repoOverride string) OutcomeReport {
13 repo := resolveItemRepo(item, repoOverride)
14 num := resolveItemNumber(item)
15 outcomeEvalLabelLog.Printf("Evaluating add_labels outcome: repo=%s, number=%d", repo, num)
16 report := OutcomeReport{
17 Type: item.Type,
18 ObjectURL: item.URL,
19 ObjectNumber: num,
20 Repo: repo,
21 }
22 if num == 0 || repo == "" {
23 outcomeEvalLabelLog.Print("Missing issue number or repo, returning error outcome")
24 report.Result = OutcomeError
25 report.EvalError = "missing issue number or repo"
26 return report
27 }
28
29 labels, err := ghAPIGetArray(fmt.Sprintf("issues/%d/labels", num), repo)
30 if err != nil {
31 outcomeEvalLabelLog.Printf("Failed to fetch labels for %s#%d: %v", repo, num, err)
32 report.Result = OutcomeError
33 report.EvalError = err.Error()
34 return report
35 }
36
37 // We don't know exactly which labels were added (the manifest doesn't record them),
38 // so we cannot reliably verify retention. If labels are still present we report
39 // pending rather than accepted, because the current labels could differ entirely
40 // from the ones we added. Only an empty label list is a clear rejection signal.
41 if len(labels) > 0 {
42 report.Result = OutcomePending
43 report.Detail = "cannot evaluate label retention (added labels not recorded; extend manifest to include label names)"
44 } else {
45 report.Result = OutcomeRejected
46 report.Detail = "all labels removed"
47 }
48
49 outcomeEvalLabelLog.Printf("Label evaluation result: result=%s, label_count=%d", report.Result, len(labels))
50 return report
51}

Callers

nothing calls this directly

Calls 6

resolveItemRepoFunction · 0.85
resolveItemNumberFunction · 0.85
ghAPIGetArrayFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected