T8782: Add opt-in auto-update rule for stale PRs (label=auto-update)#8
Conversation
When a PR carries the `auto-update` label and has at least one commit
behind its base branch, merge the base into the PR via the `update`
action. Skipped on drafts, conflicts, closed/merged, and
`backport-conflict` so the rule doesn't interfere with the conflict
workspace.
Why `update` and not `rebase`:
1. Fork-safe — `rebase` loses fork support 2026-07-01 per Mergify
docs; `update` works on fork PRs indefinitely. Important for
vyos/vyos-1x and vyos/vyos-documentation community contributions.
2. Mirror-pipeline-safe — gen-1 cross-org mirroring (vyos → VyOS-
Networks) copies refs by SHA. Rebase rewrites SHAs and would
create mirror noise or break consumer PRs. `update` preserves
SHAs.
3. CI-cache-friendly — one new merge commit triggers one re-run;
rebase changes every SHA and re-runs the entire PR.
Opt-in via label so this isn't a fleet-wide behavior change. Repos
that want it apply the `auto-update` label to PRs (per-PR or via
per-repo default-label automation); repos that don't, ignore the
rule.
📝 WalkthroughWalkthroughAdds an opt-in Mergify rule (lines 132–175) that auto-updates PRs labeled ChangesAuto-update PR Rule
Pre-push CodeRabbit review and docs
Possibly Related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@copilot review |
Reviewed current PR state and CI workflow runs; there are no failing jobs attributable to this change, and no additional code changes are needed at this time. Current commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.githooks/pre-push (1)
36-37: ⚡ Quick winAdd a preflight check for
origin/productionbefore running CodeRabbit.If
origin/productionis missing locally (common in fresh/fork clones), the hook fails late with a less actionable CLI error.Proposed fix
echo "pre-push: running coderabbit review against origin/production..." >&2 +if ! git rev-parse --verify --quiet origin/production >/dev/null; then + echo "pre-push: base ref origin/production not found locally." >&2 + echo "run: git fetch origin production" >&2 + echo "to bypass: git push --no-verify" >&2 + exit 1 +fi if ! output="$(coderabbit review --base origin/production --agent 2>&1)"; then🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.githooks/pre-push around lines 36 - 37, The hook currently calls "coderabbit review --base origin/production" without ensuring the remote ref exists, causing a confusing failure in fresh/fork clones; add a preflight check before the call to verify the presence of origin/production (e.g., run a git command like "git rev-parse --verify --quiet refs/remotes/origin/production" or "git ls-remote --exit-code origin production") and if the check fails print a clear actionable message and exit non‑zero; update the logic around the existing lines that run coderabbit review (the if ! output="$(coderabbit review --base origin/production --agent 2>&1)"; then ...) so the check runs first and short-circuits with a helpful error when origin/production is missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.githooks/pre-push:
- Around line 36-37: The hook currently calls "coderabbit review --base
origin/production" without ensuring the remote ref exists, causing a confusing
failure in fresh/fork clones; add a preflight check before the call to verify
the presence of origin/production (e.g., run a git command like "git rev-parse
--verify --quiet refs/remotes/origin/production" or "git ls-remote --exit-code
origin production") and if the check fails print a clear actionable message and
exit non‑zero; update the logic around the existing lines that run coderabbit
review (the if ! output="$(coderabbit review --base origin/production --agent
2>&1)"; then ...) so the check runs first and short-circuits with a helpful
error when origin/production is missing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 5793fd0a-b3fe-49b6-91c1-000d263b74b5
📒 Files selected for processing (2)
.githooks/pre-pushREADME.md
📜 Review details
🧰 Additional context used
🔍 Remote MCP Context7
Additional factual context for reviewing the PR (concise)
- Mergify supports an
updateaction for pull_request_rules that updates a PR by merging the base branch into the PR (example usage matches the PR's pattern, including filtering out drafts with-draft). - The update behavior can be controlled with
update_methodwhich acceptsmergeorrebase. If unspecified (null) it defaults tomerge(unlessmerge_method: fast-forwardis set, which defaultsupdate_methodtorebase) — so the PR’s use ofupdatewill default to merge semantics (preserving original commit SHAs) unless a repo-level queue/merge_method overrides it. - Rebase-based updates rewrite commit SHAs (creates new commits) and are explicitly documented as the behavior when
update_method: rebaseis used; this supports the PR rationale that using merge preserves SHAs, reviewer threads, fork support, and avoids force-push semantics that can break SHA-based mirroring. - Example from Mergify docs shows the same opt-in-by-label pattern (label +
-draft) used in this PR’s rule (docs useupdate:under actions) — the PR’s condition syntax and negation usage (-draft,-closed, etc.) aligns with documented examples. - Source resolved for these docs: the official Mergify documentation (Context7 library: /websites/mergify).
Sources used
- Context7 resolve call that returned the Mergify library entry.
- Context7 query to Mergify docs for
updateaction,update_methodbehavior, rebase vs merge implications, and example rule patterns.
🔇 Additional comments (2)
README.md (1)
1-55: LGTM!.githooks/pre-push (1)
26-26: ⚡ Quick winNo changes needed. The current loop guard does not trigger an unbound variable error under
set -uwith empty stdin. Testing confirms the unguarded[[ -n "$local_ref" ]]pattern succeeds on empty input, contradicting the original concern. The code is correct as written.> Likely an incorrect or invalid review comment.
64e700f to
83adbe3
Compare
Summary
Add a
pull_request_rulesentry that auto-refreshes a PR with its base branch when the PR carries theauto-updatelabel and has at least one commit behind base. Uses theupdateaction (merges base into PR via merge commit), notrebase.Mirrors VyOS-Networks/mergify (separate PR).
Behavior
Result: one new merge commit on the PR branch carrying the latest base. SHAs of prior commits are preserved.
Why
updateand notrebaserebaseupdate(this PR)Forks matter for vyos/vyos-1x and vyos/vyos-documentation (community contributions). The mirror pipeline is the biggest tilt: gen-1 mirroring copies refs by SHA; a force-pushed rebase on the vyos side creates SHAs the VyOS-Networks mirror has never seen.
Why opt-in via label
Central config inherits to every
extends: mergifyconsumer (~40 repos active, ~144 in scope post-T8852). A fleet-wide auto-update default is a behavior change everyone gets at once. Label-gating keeps adoption controlled:auto-updateto relevant PRs (per-PR or via per-repo default-label automation).Why the carveouts
-draft— drafts are pre-review; updates are noise.-conflict— already-conflicted PRs need human attention (the existingLabel conflicting pull requestsrule labels them).-label=backport-conflict— defense-in-depth against fighting the conflict workspace shipped in vyos/mergify#7.-closed,-merged— terminal states.Inheritance
Same as other
pull_request_rulesentries: per-repo configs can override by defining a same-named rule locally (Auto-update PR when behind base (opt-in via label)). The descriptive rule name makes accidental collisions unlikely.Related
🤖 Generated by robots