build: force upstream fetch before merge (#21192)

PR Close #21192
This commit is contained in:
Miško Hevery 2017-12-27 15:04:51 -08:00
parent 9f538a6cac
commit bc7a6d7b00
2 changed files with 7 additions and 22 deletions

View File

@ -7,30 +7,11 @@ Caretaker is responsible for merging PRs into the individual branches and intern
- 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) - 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)
- Assigining [new issues](https://github.com/angular/angular/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) to individual component authors. - Assigining [new issues](https://github.com/angular/angular/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) to individual component authors.
## Setup
### Set `upstream` to fetch PRs into your local repo
Use this conmmands to configure your `git` to fetch PRs into your local repo.
```
git remote add upstream git@github.com:angular/angular.git
git config --add remote.upstream.fetch +refs/pull/*/head:refs/remotes/upstream/pr/*
```
## Merging the PR ## Merging the PR
A PR needs to have `PR action: merge` and `PR target: *` labels to be considered 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. ready to merge. Merging is performed by running `merge-pr` with a PR number to merge.
NOTE: before running `merge-pr` ensure that you have synced all of the PRs
locally by running:
```
$ git fetch upstream
```
To merge a PR run: To merge a PR run:
``` ```
@ -40,6 +21,7 @@ $ ./scripts/github/merge-pr 1234
The `merge-pr` script will: The `merge-pr` script will:
- Ensure that all approriate labels are on the PR. - Ensure that all approriate labels are on the PR.
- That the current branch (`master` or `?.?.x` patch) mathches the `PR target: *` label. - That the current branch (`master` or `?.?.x` patch) mathches the `PR target: *` label.
- Fetches the latest PR code from the `angular/angular` repo.
- It will `cherry-pick` all of the SHAs from the PR into the current branch. - It will `cherry-pick` all of the SHAs from the PR into the current branch.
- It will rewrite commit history by automatically adding `Close #1234` and `(#1234)` into the commit message. - It will rewrite commit history by automatically adding `Close #1234` and `(#1234)` into the commit message.
@ -53,8 +35,8 @@ $ ./scripts/github/merge-pr 1234
====================== ======================
GitHub Merge PR Steps GitHub Merge PR Steps
====================== ======================
git cherry-pick upstream/pr/1234~1..upstream/pr/1234 git cherry-pick angular/pr/1234~1..angular/pr/1234
git filter-branch -f --msg-filter "/usr/local/google/home/misko/angular-pr/scripts/github/utils/github.closes 1234" HEAD~1..HEAD git filter-branch -f --msg-filter "/home/misko/angular/scripts/github/utils/github.closes 1234" HEAD~1..HEAD
``` ```
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 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

View File

@ -67,17 +67,20 @@ else
fi fi
CHERRY_PICK_PR="git cherry-pick upstream/pr/$PR_NUMBER~$PR_SHA_COUNT..upstream/pr/$PR_NUMBER" FETCH_PR="git fetch https://github.com/angular/angular.git pull/$PR_NUMBER/head:angular/pr/$PR_NUMBER"
CHERRY_PICK_PR="git cherry-pick angular/pr/$PR_NUMBER~$PR_SHA_COUNT..angular/pr/$PR_NUMBER"
REWRITE_MESSAGE="git filter-branch -f --msg-filter \"$BASEDIR/utils/github_closes.js $PR_NUMBER\" HEAD~$PR_SHA_COUNT..HEAD" REWRITE_MESSAGE="git filter-branch -f --msg-filter \"$BASEDIR/utils/github_closes.js $PR_NUMBER\" HEAD~$PR_SHA_COUNT..HEAD"
echo "======================" echo "======================"
echo "GitHub Merge PR Steps" echo "GitHub Merge PR Steps"
echo "======================" echo "======================"
echo " $FETCH_PR"
echo " $CHERRY_PICK_PR" echo " $CHERRY_PICK_PR"
echo " $REWRITE_MESSAGE" echo " $REWRITE_MESSAGE"
echo "----------------------" echo "----------------------"
echo ">>> Cherry Pick: $CHERRY_PICK_PR" echo ">>> Cherry Pick: $CHERRY_PICK_PR"
$FETCH_PR
$CHERRY_PICK_PR $CHERRY_PICK_PR
echo echo