Add prepare-patch.sh to backport pending PRs before a patch release - #722
Merged
Conversation
Lets you multi-select PRs merged to main since a release branch diverged, cherry-picks them onto one branch, validates the build, and opens a combined PR. Wired into release.sh's patch flow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
macOS ships bash 3.2 which lacks the mapfile builtin, breaking these scripts when run under /bin/bash instead of a newer bash. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds an explicit check that a local branch (if checked out) matches origin before proceeding, with correct pull guidance instead of the misleading "push" hint that only fit the ahead-of-origin case. Also fixes select_commit and the ancestor check to read origin/$BRANCH directly, since a branch picked via the interactive picker usually has no local ref of the same name and previously failed with "unknown revision". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
read_key() now guards against a failed read under set -u, and both scripts trap SIGINT to exit cleanly instead of crashing with an unbound-variable error. Docs updated for the origin-freshness check and the new cancel behavior.
Contributor
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 456938669b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Contributor
CI Test ResultsRun: #31195153567 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-08-07 16:15:34 UTC |
Contributor
Fix down-arrow arithmetic exiting pickers under set -e, empty confirmations backporting PR #0, prep branch inheriting stale local commits, already-backported PRs reappearing as candidates, merge-commit cherry-picks failing without a mainline, and the backport prompt hanging without a TTY.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?:
Adds
utils/prepare-patch.sh, invoked fromrelease.sh's patch-release flow, to let a maintainer interactively pick PRs merged tomainsince a release branch diverged, cherry-pick the selection onto one combined branch, validate the build (./gradlew buildDebug), and open a single combined backport PR.Motivation:
Preparing a patch release currently requires manually finding and cherry-picking candidate PRs one at a time with
backport-pr.sh. This adds a guided, interactive step torelease.shfor patch releases: pick a release branch, pick which pendingmainPRs to backport, and get one combined PR to review and merge before releasing.Along the way, this also:
release.sh/prepare-patch.shinteractive pickers crashing with an "unbound variable" error on Ctrl-C (set -u+ an interruptedread).mapfileusage that isn't available under macOS's stock bash 3.2.originbefore proceeding.Additional Notes:
Both interactive pickers (release branch, commit, PR multi-select) support arrow-key navigation and can be cancelled at any time with
qor Ctrl-C.How to test the change?:
bash -n utils/release.sh utils/prepare-patch.shandshellcheckpass cleanly.utils/release.sh --helpandutils/prepare-patch.sh --helpunder/bin/bash(macOS stock bash 3.2) to confirm nomapfilecrash.q, and confirmed no crash.utils/prepare-patch.shdefaults to dry-run; verified the dry-run summary against a real release branch/PR set without pushing or opening a PR.For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.Unsure? Have a question? Request a review!