Skip to content

Cherry picks to a release channel

Alexander Thomas edited this page May 2, 2023 · 42 revisions

Cherry-picking is the process of selecting and merging an existing bug fix from our main development branch into a release branch (e.g. from main to beta or stable) for inclusion into the next hotfix release.

With the Dart and Flutter joint release process, we're using a combined Dart & Flutter Cherrypick Review and Approval Process. This document is a supplement to the main process and describes the process and flow within the Dart team.

Note: This process applies to bugs and regressions. Feature work is not considered for cherry picking and will need to wait for the next release.

Notice a cherry-pick is required

Resolve the issue and land the fix on the main branch along with tests to confirm whether the issue was in fact fixed. Identity whether the latest beta and stable releases contain the issue and judge whether the fix should be backported. Two changelists may be required if both channels are affected.

Upload cherry-pick as a changelist

Cherry-pick your changelist's commit onto a new branch targeting beta or stable:

$ git fetch
$ git new-branch --upstream origin/stable cherry    # or origin/beta
$ git cherry-pick --edit $commit

Update the commit message accordingly:

  1. Add a [beta] or [stable] gerrit hashtag at the start of the first line.
  2. Rename the Reviewed-on field to Cherry-pick to link to the original changelist being cherry-picked.
  3. Remove the conflicting fields Change-id, Commit-queue, Reviewed-by that are not true of the new changelist.

E.g.:

[stable] Fix foo crash.

Avoid foo doing bar instead.

Add reproducing test case.

Bug: https://github.com/dart-lang/sdk/issues/12345678
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/12345678

For stable, consider adding a CHANGELOG.md entry about the issue or the release leads will write one when authoring the next patch release.

Upload the changelist to gerrit for approval:

git cl upload

Trigger a commit queue dry run and add any appropriate try builders to confirm the fix is correct.

Request cherry-pick approval

Request approval for releasing the fix to beta/stable using this cherry-pick to beta/stable request template:

  • Brief description of the problem.
  • The reason for cherry pick, user impact, and a brief risk assessment (low/medium/high).
  • Link to the changelist.
  • The cherry-pick-review label.

Edit the changelist's commit message with a link to the cherry-pick request to close it upon the changelist landing:

Fixes: https://github.com/dart/sdk/issues/56781234

Send the changelist for review. Await the appropriate consensus and approval via the cherry-pick-approved for them or any OWNER to review the changelist.

Once the cherry-pick issue is approved and the changelist is reviewed, the cherry-pick author will submit it to the commit queue. The tryjobs will compare the test results with the previous commit on the beta/stable branch and fail if any regressions are introduced. If any regressions must be introduced, or the try builders don't work on the older beta/stable code, then bypass the commit queue by force submitting.

The release engineers will apply the cherry-pick-merged label and the cherry-pick will be automatically bundled into the next hotfix release of beta/stable and no further actions are required.

Once the cherry-pick has landed in a hotfix release, the release engineering team will close the cherry-pick issue.

Cherry-picking a commit in a dependency.

If you need to cherry pick a single commit (here $commit-to-cherry-pick) in a dependency (here third-party/pkg/pub) to a release-channel (here beta).

First in the SDK checkout, find the current revision at the release branch:

dart-sdk/sdk/ > git checkout beta && git pull
dart-sdk/sdk/ > gclient getdep -r sdk/third_party/pkg/pub
a3f8b2fd36ec432450caf907474a02023ef3e44e

Now in a clone of the dependency, create a cherry-pick on a new branch, and push it to the origin repo:

pub/ > git checkout -b cherry-pick a3f8b2fd36ec432450caf907474a02023ef3e44e
pub/ > git cherry-pick $commit-to-cherry-pick
pub/ > git push -u origin cherry_pick:cherry_pick
pub/ > git rev-parse HEAD
6d1857c84cfb8a014aefedaf2d453214bf5ddb96 # <-- this is the revision we want to move to.

Wait a little while for the change to be mirrored to dart.googlesource.com.

Now, go back to the SDK checkout, create a bump-commit and a CL that moves the release-channel to the new commit using the manage-deps tool:

dart-sdk/sdk/ > tools/manage_deps.dart bump third_party/pkg/pub --target=6d1857c84cfb8a014aefedaf2d453214bf5ddb96

Update the CL to be relative to the release-channel:

dart-sdk/sdk/ > git branch --set-upstream-to=origin/beta
dart-sdk/sdk/ > git cl upload

This CL can be used in the cherry-pick flow above. Remember to mark it active for review.

After the CL has been merged we need to ensure that the cherry-picked commit on the dependency gets merged into the protected branch (here main). Otherwise there is a risk it will be GC'ed.

The following commands should create such a merge. (Inspired by https://stackoverflow.com/questions/47670237/how-to-merge-a-branch-into-master-without-changes)

pub/ > git merge origin/main -sours # Create a merge commit with the protected branch and the cherry pick as parents.
Merge made by the 'ours' strategy.
pub/ > git rev-parse HEAD # Find the current commit ID
b6cfdcfedfdda95b1d4d08d93a325fbecc6a7e5b
pub/ > git reset origin/main --hard # Reset worktree to be as on main
HEAD is now at ....
pub/ > git reset b6cfdcfedfdda95b1d4d08d93a325fbecc6a7e5b --soft # Make the branch point to the merge
pub/ > git ci --amend -a --no-edit # Update the merge commit to have no changes relative to main.

Now create a PR for this merge, and make sure to "merge" instead of "squash" it (you might have to temporarily change repo settings to do this).

Clone this wiki locally