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

Function findPRByTimestamp

pkg/cli/outcome_eval_pr.go:16–46  ·  view source on GitHub ↗

findPRByTimestamp searches for a PR created by github-actions[bot] around the given timestamp. This is a fallback for when the manifest doesn't record the PR number.

(repo string, timestamp string)

Source from the content-addressed store, hash-verified

14// findPRByTimestamp searches for a PR created by github-actions[bot] around the given timestamp.
15// This is a fallback for when the manifest doesn't record the PR number.
16func findPRByTimestamp(repo string, timestamp string) int {
17 outcomeEvalPRLog.Printf("Searching for PR by timestamp: repo=%s, timestamp=%s", repo, timestamp)
18 ts, err := time.Parse(time.RFC3339, timestamp)
19 if err != nil {
20 outcomeEvalPRLog.Printf("Failed to parse timestamp %q: %v", timestamp, err)
21 return 0
22 }
23 // Search in a 5-minute window around the timestamp
24 since := ts.Add(-2 * time.Minute).Format("2006-01-02T15:04:05Z")
25 until := ts.Add(5 * time.Minute).Format("2006-01-02T15:04:05Z")
26
27 // Use gh CLI to search for PRs
28 output, err := workflow.RunGH("Searching for PR...",
29 "pr", "list",
30 "--repo", repo,
31 "--state", "all",
32 "--author", "app/github-actions",
33 "--search", fmt.Sprintf("created:%s..%s", since, until),
34 "--limit", "1",
35 "--json", "number",
36 "--jq", ".[0].number")
37 if err != nil {
38 return 0
39 }
40 numStr := strings.TrimSpace(string(output))
41 var n int
42 if _, err := fmt.Sscanf(numStr, "%d", &n); err == nil {
43 return n
44 }
45 return 0
46}
47
48// evalCreatePullRequest checks whether a PR was merged, closed, or is still open.
49func evalCreatePullRequest(item CreatedItemReport, repoOverride string) OutcomeReport {

Callers 1

evalCreatePullRequestFunction · 0.85

Calls 3

RunGHFunction · 0.92
PrintfMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected