2017-07-26 15:37:14 -04:00
# Caretaker
Caretaker is responsible for merging PRs into the individual branches and internally at Google.
## Responsibilities
- 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)
2018-01-23 19:49:20 -05:00
- Assigning [new issues ](https://github.com/angular/angular/issues?q=is%3Aopen+is%3Aissue+no%3Alabel ) to individual component authors.
2017-07-26 15:37:14 -04:00
## Merging the PR
A PR needs to have `PR action: merge` and `PR target: *` labels to be considered
ready to merge. Merging is performed by running `merge-pr` with a PR number to merge.
To merge a PR run:
```
$ ./scripts/github/merge-pr 1234
```
The `merge-pr` script will:
2018-01-23 19:49:20 -05:00
- Ensure that all appropriate labels are on the PR.
2017-12-27 18:04:51 -05:00
- Fetches the latest PR code from the `angular/angular` repo.
2018-01-23 19:49:20 -05:00
- It will `cherry-pick` all of the SHAs from the PR into the current corresponding branches `master` and or `?.?.x` (patch).
2017-07-26 15:37:14 -04:00
- It will rewrite commit history by automatically adding `Close #1234` and `(#1234)` into the commit message.
2018-01-23 19:49:20 -05:00
NOTE: The `merge-pr` will land the PR on `master` and or `?.?.x` (patch) as described by `PR target: *` label.
2017-07-26 15:37:14 -04:00
### Recovering from failed `merge-pr` due to conflicts
When running `merge-pr` the script will output the commands which it is about to run.
```
$ ./scripts/github/merge-pr 1234
======================
GitHub Merge PR Steps
======================
2017-12-27 18:04:51 -05:00
git cherry-pick angular/pr/1234~1..angular/pr/1234
git filter-branch -f --msg-filter "/home/misko/angular/scripts/github/utils/github.closes 1234" HEAD~1..HEAD
2017-07-26 15:37:14 -04:00
```
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
## Cherry-picking PRs into patch branch
In addition to merging PRs into the master branch, many PRs need to be also merged into a patch branch.
2017-08-28 21:43:52 -04:00
Follow these steps to get patch branch up to date.
2017-07-26 15:37:14 -04:00
1. Check out the most recent patch branch: `git checkout 4.3.x`
2. Get a list of PRs merged into master: `git log master --oneline -n10`
2018-08-17 13:18:35 -04:00
3. For each PR number in the commit message run: `./scripts/github/merge-pr 1234`
2017-07-26 15:37:14 -04:00
- The PR will only merge if the `PR target:` matches the branch.
Once all of the PRs are in patch branch, push the all branches and tags to github using `push-upstream` script.
## Pushing merged PRs into github
Use `push-upstream` script to push all of the branch and tags to github.
```
$ ./scripts/github/push-upstream
git push git@github.com:angular/angular.git master:master 4.3.x:4.3.x
Counting objects: 25, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (25/25), 2.22 KiB | 284.00 KiB/s, done.
Total 25 (delta 22), reused 8 (delta 7)
remote: Resolving deltas: 100% (22/22), completed with 18 local objects.
To github.com:angular/angular.git
079d884b6..d1c4a94bb master -> master
git push --tags -f git@github.com:angular/angular.git patch_sync:patch_sync
Everything up-to-date
2017-08-28 21:43:52 -04:00
```