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-red-pr-kick-resign-only-when-gated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **The red-PR fix kick asks for a DCO re-sign only where DCO is enforced.** `no-dco` is written on every managed repo but gates only where the repository enforces DCO ([#12544](https://github.com/hivecommons/hive/issues/12544)); the FIX-BEFORE-NEW kick nonetheless told the fixer, whenever the label was present, to re-sign the PR's commits and `git push --force-with-lease` first β€” on a Renovate-style bot branch in a repo with no DCO gate, a rewrite nothing asked for. The re-sign is now the required first step only when a `DCO` check is among the failing checks; otherwise the kick carries one note to re-sign only if the repository asks for it.
13 changes: 11 additions & 2 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9306,9 +9306,18 @@ func redPRFixKick(o escalation.Observation, rerouted bool) string {
fmt.Fprintf(&b, "Its owning agent (%s) is not reachable right now, so this repair is routed to you.\n\n", redPRFixOwner(o.Agent))
}
b.WriteString("Repair it BEFORE claiming new issues or opening any new PR:\n")
// `no-dco` is written on every managed repo but gates only where DCO is
// enforced (hivecommons/hive#12544): a re-sign is the first repair only
// when a DCO check is among the failures. Elsewhere β€” a Renovate-style
// bot branch in a repo with no DCO gate β€” demanding a force-pushed
// re-sign would rewrite a branch nothing asked to change.
if slices.Contains(o.Labels, stagelabels.NoDCOLabel) {
fmt.Fprintf(&b, " FIRST (required): the PR is %s β€” it inherited unsigned commits. Re-sign them: gh pr checkout %d --repo %s β†’ git rebase --signoff <base> (original authors preserved) β†’ git push --force-with-lease\n", stagelabels.NoDCOLabel, o.Number, o.Repo)
b.WriteString(" THEN fix any failing CI the same way.\n")
if slices.ContainsFunc(o.FailingChecks, github.IsDCOContext) {
fmt.Fprintf(&b, " FIRST (required): the PR is %s β€” it inherited unsigned commits. Re-sign them: gh pr checkout %d --repo %s β†’ git rebase --signoff <base> (original authors preserved) β†’ git push --force-with-lease\n", stagelabels.NoDCOLabel, o.Number, o.Repo)
b.WriteString(" THEN fix any failing CI the same way.\n")
} else {
fmt.Fprintf(&b, " Note: the PR carries %s, but no DCO check is failing here; re-sign its commits only if this repository asks for it. Fix the failing CI first.\n", stagelabels.NoDCOLabel)
}
}
fmt.Fprintf(&b, " gh pr checkout %d --repo %s β†’ fix β†’ git commit -s β†’ git push\n", o.Number, o.Repo)
b.WriteString("Push to the SAME branch. Do NOT open a replacement PR.\n")
Expand Down
19 changes: 19 additions & 0 deletions src/cmd/hive/redpr_fix_kick_no_ci_wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,22 @@ func TestRedPRFixKickNamesDCORehomeFirstForNoDCO(t *testing.T) {
t.Errorf("DCO action leaked into a signed PR's kick:\n%s", plain)
}
}

// `no-dco` is written on every managed repo but gates only where DCO is
// enforced (#12544). A red bot PR in a repo with no DCO check must not be told
// to force-push re-signed commits; it gets one soft note instead.
func TestRedPRFixKickDemandsResignOnlyWhenDCOGates(t *testing.T) {
ungated := redPRFixKick(escalation.Observation{Repo: "projectbluefin/utah", Number: 987, Labels: []string{"no-dco"}, FailingChecks: []string{"build_main"}}, false)
if strings.Contains(ungated, "FIRST (required)") || strings.Contains(ungated, "git rebase --signoff") || strings.Contains(ungated, "--force-with-lease") {
t.Errorf("ungated no-dco kick still demands a re-sign:\n%s", ungated)
}
if !strings.Contains(ungated, "no DCO check is failing here") {
t.Errorf("ungated no-dco kick lacks the soft note:\n%s", ungated)
}
for _, gate := range []string{"DCO", "dco"} {
gated := redPRFixKick(escalation.Observation{Repo: "hivecommons/hive", Number: 1, Labels: []string{"no-dco"}, FailingChecks: []string{"build", gate}}, false)
if !strings.Contains(gated, "FIRST (required)") {
t.Errorf("gated (%s) no-dco kick lost the re-sign:\n%s", gate, gated)
}
}
}
Loading