Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-park-recheck-option-refs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The park re-check no longer calls a decision park out of date because a PR its evidence merely lists merged. projectbluefin/server#614 parked on #583 (both options merge it) and listed #584 and #588 among the PRs its red check touched; the re-check reported those two merging as "the park reason names it" while #583 was still open. When a park's lettered options name references, only those count; a park without options, or with options that name none, keeps every named reference.
5 changes: 4 additions & 1 deletion src/docs/maintainer-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ When, after the park began, a PR or issue the park text names merged or
closed, or a PR that refers to the issue ("Refs #N", a closing keyword, "part
of", …, a list of at most 10 references) merged, Hive posts one note
(`<!-- hive:park-recheck -->`) listing what changed, and edits it in place as
more moves. When such a PR closed unmerged because the hive adopted it, Hive
more moves. When the park offers lettered options that name references, only
those references count as what the park waits on; the rest of its text is
evidence. projectbluefin/server#614 parked on #583, which both options merge,
and the PRs listed only as also red (#584, #588) no longer trigger the note. When such a PR closed unmerged because the hive adopted it, Hive
follows it to the hive's copy (the App PR whose body says `Supersedes #N`)
and lists the copy too if it merged or closed unmerged; when a person closed
the copy, the note quotes the first paragraph of their closing comment (at
Expand Down
28 changes: 28 additions & 0 deletions src/pkg/github/issue_park_recheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func (c *Client) recheckParkedIssue(ctx context.Context, owner, repo string, iss
refs := parkRefsFromTimeline(events)
text := c.parkText(issue, comments, start)
named := parkNamedRefs(text, owner+"/"+repo, number)
if acted := parkOptionRefs(text, owner+"/"+repo, number); len(acted) > 0 {
named = acted
}
lookups := 0
for _, key := range named {
if _, ok := refs[key]; ok || lookups >= parkRecheckMaxNamedLookups {
Expand Down Expand Up @@ -392,6 +395,31 @@ func parkNamedRefs(text, issueRepo string, number int) []string {
return out
}

// parkOptionRefs returns the references the park's lettered options name:
// each option line and the lines under it, up to a blank line or the next
// option. A park that offers options waits on what they act on; the rest of
// its text is evidence. projectbluefin/server#614 parked on #583 (both
// options merge it) and listed #584 and #588 among the PRs its red check
// touched; the re-check reported those two merging as "the park reason names
// it" while #583 was still open. nil when the park lists no options, so a
// park without options keeps every named reference.
func parkOptionRefs(text, issueRepo string, number int) []string {
var block []string
inOption := false
for _, line := range strings.Split(text, "\n") {
switch {
case unparkOptionLetter(line) != "":
inOption = true
block = append(block, line)
case strings.TrimSpace(line) == "":
inOption = false
case inOption:
block = append(block, line)
}
}
return parkNamedRefs(strings.Join(block, "\n"), issueRepo, number)
}

func parkRefKey(repo string, n int) string {
return strings.ToLower(strings.TrimSpace(repo)) + "#" + strconv.Itoa(n)
}
Expand Down
71 changes: 71 additions & 0 deletions src/pkg/github/issue_park_recheck_options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package github

import (
"strings"
"testing"
"time"
)

// projectbluefin/server#614 parked on #583 (both options merge it); #584 and
// #588 appear only in the evidence ("red on `main` and on PRs #583, #584,
// #588, #594, #613"). The re-check reported #584 and #588 merging as "the
// park reason names it" while #583 stayed open.
const park614 = "**Summary:** prow keeps failing because it tries to merge #583, which edits the build automation.\n\n" +
"- Check: `prow / prow`, red on `main` (cron) and on PRs #583, #584, #588, #594, #613.\n" +
"- Separately, #588's last red run was `HttpError: Service Unavailable` (a GitHub 503), not this cause.\n\n" +
"Option A: Add the `workflow` scope to the token prow uses for merges, then let the cron merge #583.\n" +
"Option B: Merge #583 by hand once; the cron stops retrying it.\n\n" +
"Recommended: B, because it unblocks today."

func TestParkRecheckOptionsNameWhatTheParkWaitsOn(t *testing.T) {
t.Run("collateral PRs merge, the option's PR is open: no note", func(t *testing.T) {
f := prParkedIssue(614, park614)
f.timeline = append(f.timeline,
prCrossRef("org/repo", 584, true, "closed", parkT0.Add(16*24*time.Hour), parkT0.Add(16*24*time.Hour), "chore: bump"),
prCrossRef("org/repo", 588, true, "closed", parkT0.Add(16*24*time.Hour), parkT0.Add(16*24*time.Hour), "fix: retry"),
prCrossRef("org/repo", 583, true, "open", time.Time{}, time.Time{}, "ci: build.yml"))
recheck(t, f)
if len(f.posted) != 0 {
t.Fatalf("posted %q, want no note while #583 is open", f.posted)
}
})
t.Run("the option's PR merges: note names it", func(t *testing.T) {
f := prParkedIssue(614, park614)
f.timeline = append(f.timeline,
prCrossRef("org/repo", 588, true, "closed", parkT0.Add(16*24*time.Hour), parkT0.Add(16*24*time.Hour), "fix: retry"),
prCrossRef("org/repo", 583, true, "closed", parkT0.Add(17*24*time.Hour), parkT0.Add(17*24*time.Hour), "ci: build.yml"))
recheck(t, f)
if len(f.posted) != 1 {
t.Fatalf("posted %q", f.posted)
}
wantNote(t, f.posted[0], "- #583 merged on 2026-10-20 (the park reason names it).")
if strings.Contains(f.posted[0], "#588") {
t.Fatalf("collateral #588 listed:\n%s", f.posted[0])
}
})
}

// Options that name no reference leave every named reference in play.
func TestParkRecheckOptionsWithoutRefsKeepNamedRefs(t *testing.T) {
f := prParkedIssue(13, "Open PR #722 finishes most of the gate.\n\nOption A: wait for it\nOption B: close this issue")
f.timeline = append(f.timeline, prCrossRef("org/repo", 722, true, "closed", parkT0.Add(21*24*time.Hour), time.Time{}, "ci: gate"))
recheck(t, f)
if len(f.posted) != 1 {
t.Fatalf("posted %q", f.posted)
}
wantNote(t, f.posted[0], "- #722 was closed without merging")
}

func TestParkOptionRefs(t *testing.T) {
if got := parkOptionRefs(park614, "org/repo", 614); len(got) != 1 || got[0] != "org/repo#583" {
t.Fatalf("option refs = %v, want only #583", got)
}
// An option's own continuation lines count; a blank line ends it.
text := "**A. Pin the tag.**\nWait for #12 to land.\n\nSee also #99.\n**B. Drop it.**"
if got := parkOptionRefs(text, "org/repo", 1); len(got) != 1 || got[0] != "org/repo#12" {
t.Fatalf("option refs = %v, want #12 from the continuation line", got)
}
if got := parkOptionRefs("Waits on #12 and #13.", "org/repo", 1); got != nil {
t.Fatalf("no options: %v, want nil (every named ref counts)", got)
}
}
Loading