• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# How to backport a pull request to a release line
2
3## Staging branches
4
5Each release line has a staging branch that the releaser will use as a scratch
6pad while preparing a release. The branch name is formatted as follows:
7`vN.x-staging` where `N` is the major release number.
8
9For the active staging branches see the [Release Schedule][].
10
11## What needs to be backported?
12
13If a cherry-pick from master does not land cleanly on a staging branch, the
14releaser will mark the pull request with a particular label for that release
15line (e.g. `backport-requested-vN.x`), specifying to our tooling that this
16pull request should not be included. The releaser will then add a comment
17requesting that a backport pull request be made.
18
19## What can be backported?
20
21The "Current" release line is much more lenient than the LTS release lines in
22what can be landed. Our LTS release lines (see the [Release Plan][])
23require that commits mature in the Current release for at least 2 weeks before
24they can be landed in an LTS staging branch. Only after "maturation" will those
25commits be cherry-picked or backported.
26
27## How to submit a backport pull request
28
29For the following steps, let's assume that a backport is needed for the v10.x
30release line. All commands will use the `v10.x-staging` branch as the target
31branch. In order to submit a backport pull request to another branch, simply
32replace that with the staging branch for the targeted release line.
33
341. Checkout the staging branch for the targeted release line.
352. Make sure that the local staging branch is up to date with the remote.
363. Create a new branch off of the staging branch, as shown below.
37
38    ```bash
39    # Assuming your fork of Node.js is checked out in $NODE_DIR,
40    # the origin remote points to your fork, and the upstream remote points
41    # to git://github.com/nodejs/node
42    cd $NODE_DIR
43    # If v10.x-staging is checked out `pull` should be used instead of `fetch`
44    git fetch upstream v10.x-staging:v10.x-staging -f
45    # Assume we want to backport PR #10157
46    git checkout -b backport-10157-to-v10.x v10.x-staging
47    # Ensure there are no test artifacts from previous builds
48    # Note that this command deletes all files and directories
49    # not under revision control below the ./test directory.
50    # It is optional and should be used with caution.
51    git clean -xfd ./test/
52    ```
53
544. After creating the branch, apply the changes to the branch. The cherry-pick
55   will likely fail due to conflicts. In that case, you will see something
56   like this:
57
58    ```console
59    # Say the $SHA is 773cdc31ef
60    $ git cherry-pick $SHA # Use your commit hash
61    error: could not apply 773cdc3... <commit title>
62    hint: after resolving the conflicts, mark the corrected paths
63    hint: with 'git add <paths>' or 'git rm <paths>'
64    hint: and commit the result with 'git commit'
65    ```
66
675. Make the required changes to remove the conflicts, add the files to the index
68   using `git add`, and then commit the changes. That can be done with
69   `git cherry-pick --continue`.
706. Leave the commit message as is. If you think it should be modified, comment
71   in the pull request. The `Backport-PR-URL` metadata does need to be added to
72   the commit, but this will be done later.
737. Make sure `make -j4 test` passes.
748. Push the changes to your fork.
759. Open a pull request:
76   1. Be sure to target the `v10.x-staging` branch in the pull request.
77   1. Include the backport target in the pull request title in the following
78      format: `[v10.x backport] <commit title>`.
79      Example: `[v10.x backport] process: improve performance of nextTick`
80   1. Check the checkbox labeled "Allow edits and access to secrets by
81      maintainers".
82   1. In the description add a reference to the original pull request.
83   1. Amend the commit message and include a `Backport-PR-URL:` metadata and
84      re-push the change to your fork.
85   1. Run a [`node-test-pull-request`][] CI job (with `REBASE_ONTO` set to the
86      default `<pr base branch>`)
8710. If during the review process conflicts arise, use the following to rebase:
88    `git pull --rebase upstream v10.x-staging`
89
90After the pull request lands, replace the `backport-requested-v10.x` label
91on the original pull request with `backported-to-v10.x`.
92
93[Release Plan]: https://github.com/nodejs/Release#release-plan
94[Release Schedule]: https://github.com/nodejs/Release#release-schedule
95[`node-test-pull-request`]: https://ci.nodejs.org/job/node-test-pull-request/build
96