|
| 1 | +# How to Backport a Pull Request to a Release Line |
| 2 | + |
| 3 | +## Staging branches |
| 4 | + |
| 5 | +Each release line has a staging branch that the releaser will use as a scratch |
| 6 | +pad while preparing a release. The branch name is formatted as follows: |
| 7 | +`vN.x-staging` where `N` is the major release number. |
| 8 | + |
| 9 | +### Active staging branches |
| 10 | + |
| 11 | +| Release Line | Staging Branch | |
| 12 | +| ------------ | -------------- | |
| 13 | +| `v7.x` | `v7.x-staging` | |
| 14 | +| `v6.x` | `v6.x-staging` | |
| 15 | +| `v4.x` | `v4.x-staging` | |
| 16 | + |
| 17 | +## What needs to be backported? |
| 18 | + |
| 19 | +If a cherry-pick from master does not land cleanly on a staging branch, the |
| 20 | +releaser will mark the pull request with a particular label for that release |
| 21 | +line, specifying to our tooling that this pull request should not be included. |
| 22 | +The releaser will then add a comment that a backport is needed. |
| 23 | + |
| 24 | +## What can be backported? |
| 25 | + |
| 26 | +The "Current" release line is much more lenient than the LTS release lines in |
| 27 | +what can be landed. Our LTS release lines (v4.x and v6.x as of March 2017) |
| 28 | +require that commits mature in a Current release for at least 2 weeks before |
| 29 | +they can be landed on staging. If the commit can not be cherry-picked from |
| 30 | +master a manual backport will need to be submitted. Please see the [LTS Plan][] |
| 31 | +for more information. After that time, if the commit can be cherry-picked |
| 32 | +cleanly from master, then nothing needs to be done. If not, a backport pull |
| 33 | +request will need to be submitted. |
| 34 | + |
| 35 | +## How to submit a backport pull request |
| 36 | + |
| 37 | +For these steps, let's assume that a backport is needed for the v7.x release |
| 38 | +line. All commands will use the v7.x-staging branch as the target branch. |
| 39 | +In order to submit a backport pull request to another branch, simply replace |
| 40 | +that with the staging branch for the targeted release line. |
| 41 | + |
| 42 | +* Checkout the staging branch for the targeted release line |
| 43 | +* Make sure that the local staging branch is up to date with the remote |
| 44 | +* Create a new branch off of the staging branch |
| 45 | + |
| 46 | +```shell |
| 47 | +# Assuming your fork of Node.js is checked out in $NODE_DIR, |
| 48 | +# the origin remote points to your fork, and the upstream remote points |
| 49 | +# to git://github.com/nodejs/node |
| 50 | +cd $NODE_DIR |
| 51 | +# Fails if you already have a v7.x-staging |
| 52 | +git branch v7.x-staging upstream/v7.x-staging |
| 53 | +git checkout v7.x-staging |
| 54 | +git reset --hard upstream/v7.x-staging |
| 55 | +# We want to backport pr #10157 |
| 56 | +git checkout -b backport-10157-to-v7.x |
| 57 | +``` |
| 58 | + |
| 59 | +* After creating the branch, apply the changes to the branch. The cherry-pick |
| 60 | + will likely fail due to conflicts. In that case, you will see something this: |
| 61 | + |
| 62 | +```shell |
| 63 | +# Say the $SHA is 773cdc31ef |
| 64 | +$ git cherry-pick $SHA # Use your commit hash |
| 65 | +error: could not apply 773cdc3... <commit title> |
| 66 | +hint: after resolving the conflicts, mark the corrected paths |
| 67 | +hint: with 'git add <paths>' or 'git rm <paths>' |
| 68 | +hint: and commit the result with 'git commit' |
| 69 | +``` |
| 70 | + |
| 71 | +* Make the required changes to remove the conflicts, add the files to the index |
| 72 | + using `git add`, and then commit the changes. That can be done with |
| 73 | + `git cherry-pick --continue`. |
| 74 | +* Leave the commit message as is. If you think it should be modified, comment |
| 75 | + in the Pull Request. |
| 76 | +* Make sure `make -j4 test` passes |
| 77 | +* Push the changes to your fork and open a pull request. |
| 78 | +* Be sure to target the `v7.x-staging` branch in the pull request. |
| 79 | + |
| 80 | +### Helpful Hints |
| 81 | + |
| 82 | +* Please include the backport target in the pull request title in the following |
| 83 | + format: `(v7.x backport) <commit title>` |
| 84 | + * Ex. `(v4.x backport) process: improve performance of nextTick` |
| 85 | +* Please check the checkbox labelled "Allow edits from maintainers". |
| 86 | + This is the easiest way to to avoid constant rebases. |
| 87 | + |
| 88 | +In the event the backport pull request is different than the original, |
| 89 | +the backport pull request should be reviewed the same way a new pull request |
| 90 | +is reviewed. |
| 91 | + |
| 92 | +[LTS Plan]: https://github.com/nodejs/LTS#lts-plan |
0 commit comments