|
| 1 | +# Caretaker |
| 2 | + |
| 3 | +Caretaker is responsible for merging PRs into the individual branches and internally at Google. |
| 4 | + |
| 5 | +## Responsibilities |
| 6 | + |
| 7 | +- Draining the queue of PRs ready to be merged. (PRs with [`PR action: merge`](https://github.com/angular/angular/pulls?q=is%3Aopen+is%3Apr+label%3A%22PR+action%3A+merge%22) label) |
| 8 | +- Assigining [new issues](https://github.com/angular/angular/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) to individual component authors. |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +### Set `upstream` to fetch PRs into your local repo |
| 13 | + |
| 14 | +Use this conmmands to configure your `git` to fetch PRs into your local repo. |
| 15 | + |
| 16 | +``` |
| 17 | +git remote add upstream [email protected]:angular/angular.git |
| 18 | +git config --add remote.upstream.fetch +refs/pull/*/head:refs/remotes/upstream/pr/* |
| 19 | +``` |
| 20 | + |
| 21 | + |
| 22 | +## Merging the PR |
| 23 | + |
| 24 | +A PR needs to have `PR action: merge` and `PR target: *` labels to be considered |
| 25 | +ready to merge. Merging is performed by running `merge-pr` with a PR number to merge. |
| 26 | + |
| 27 | +NOTE: before running `merge-pr` ensure that you have synced all of the PRs |
| 28 | +locally by running: |
| 29 | + |
| 30 | +``` |
| 31 | +$ git fetch upstream |
| 32 | +``` |
| 33 | + |
| 34 | +To merge a PR run: |
| 35 | + |
| 36 | +``` |
| 37 | +$ ./scripts/github/merge-pr 1234 |
| 38 | +``` |
| 39 | + |
| 40 | +The `merge-pr` script will: |
| 41 | +- Ensure that all approriate labels are on the PR. |
| 42 | +- That the current branch (`master` or `?.?.x` patch) mathches the `PR target: *` label. |
| 43 | +- It will `cherry-pick` all of the SHAs from the PR into the current branch. |
| 44 | +- It will rewrite commit history by automatically adding `Close #1234` and `(#1234)` into the commit message. |
| 45 | + |
| 46 | + |
| 47 | +### Recovering from failed `merge-pr` due to conflicts |
| 48 | + |
| 49 | +When running `merge-pr` the script will output the commands which it is about to run. |
| 50 | + |
| 51 | +``` |
| 52 | +$ ./scripts/github/merge-pr 1234 |
| 53 | +====================== |
| 54 | +GitHub Merge PR Steps |
| 55 | +====================== |
| 56 | + git cherry-pick upstream/pr/1234~1..upstream/pr/1234 |
| 57 | + git filter-branch -f --msg-filter "/usr/local/google/home/misko/angular-pr/scripts/github/utils/github.closes 1234" HEAD~1..HEAD |
| 58 | +``` |
| 59 | + |
| 60 | +If the `cherry-pick` command fails than resolve conflicts and use `git cherry-pick --continue` once ready. After the `cherry-pick` is done cut&paste and run the `filter-branch` command to properly rewrite the messages |
| 61 | + |
| 62 | +## Cherry-picking PRs into patch branch |
| 63 | + |
| 64 | +In addition to merging PRs into the master branch, many PRs need to be also merged into a patch branch. |
| 65 | +Follow these steps to get path brach up to date. |
| 66 | + |
| 67 | +1. Check out the most recent patch branch: `git checkout 4.3.x` |
| 68 | +2. Get a list of PRs merged into master: `git log master --oneline -n10` |
| 69 | +3. For each PR number in the commit message run: `././scripts/github/merge-pr 1234` |
| 70 | + - The PR will only merge if the `PR target:` matches the branch. |
| 71 | + |
| 72 | +Once all of the PRs are in patch branch, push the all branches and tags to github using `push-upstream` script. |
| 73 | + |
| 74 | + |
| 75 | +## Pushing merged PRs into github |
| 76 | + |
| 77 | +Use `push-upstream` script to push all of the branch and tags to github. |
| 78 | + |
| 79 | +``` |
| 80 | +$ ./scripts/github/push-upstream |
| 81 | +git push [email protected]:angular/angular.git master:master 4.3.x:4.3.x |
| 82 | +Counting objects: 25, done. |
| 83 | +Delta compression using up to 6 threads. |
| 84 | +Compressing objects: 100% (17/17), done. |
| 85 | +Writing objects: 100% (25/25), 2.22 KiB | 284.00 KiB/s, done. |
| 86 | +Total 25 (delta 22), reused 8 (delta 7) |
| 87 | +remote: Resolving deltas: 100% (22/22), completed with 18 local objects. |
| 88 | +To github.com:angular/angular.git |
| 89 | + 079d884b6..d1c4a94bb master -> master |
| 90 | +git push --tags -f [email protected]:angular/angular.git patch_sync:patch_sync |
| 91 | +Everything up-to-date |
| 92 | +``` |
0 commit comments