diff --git a/changelog.d/fixed-red-pr-kick-resign-only-when-gated.md b/changelog.d/fixed-red-pr-kick-resign-only-when-gated.md new file mode 100644 index 0000000000..e5fcdcd8b5 --- /dev/null +++ b/changelog.d/fixed-red-pr-kick-resign-only-when-gated.md @@ -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. diff --git a/src/cmd/hive/main.go b/src/cmd/hive/main.go index c2ca7483a4..13730183b4 100644 --- a/src/cmd/hive/main.go +++ b/src/cmd/hive/main.go @@ -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 (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 (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") diff --git a/src/cmd/hive/redpr_fix_kick_no_ci_wait_test.go b/src/cmd/hive/redpr_fix_kick_no_ci_wait_test.go index d744b54888..4b3b25bee7 100644 --- a/src/cmd/hive/redpr_fix_kick_no_ci_wait_test.go +++ b/src/cmd/hive/redpr_fix_kick_no_ci_wait_test.go @@ -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) + } + } +}