Skip to content

Commit 917cca8

Browse files
josephperrottalan-agius4
authored andcommitted
build: set up ng-dev tooling to perform merges in the repository
Set up the configurations required for caretakers to be able to rely on ng-dev for performing merges to all targetted branches. (cherry picked from commit 64d1750)
1 parent 935465d commit 917cca8

File tree

4 files changed

+45
-46
lines changed

4 files changed

+45
-46
lines changed

.ng-dev/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { commitMessage } from './commit-message';
22
export { github } from './github';
3+
export { merge } from './merge';

.ng-dev/merge.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { DevInfraMergeConfig } from '@angular/dev-infra-private/pr/merge/config';
2+
import { getDefaultTargetLabelConfiguration } from '@angular/dev-infra-private/pr/merge/defaults';
3+
import { github } from './github';
4+
import { release } from './release';
5+
6+
/**
7+
* Configuration for the merge tool in `ng-dev`. This sets up the labels which
8+
* are respected by the merge script (e.g. the target labels).
9+
*/
10+
export const merge: DevInfraMergeConfig['merge'] = async api => {
11+
return {
12+
githubApiMerge: {
13+
default: 'squash',
14+
labels: [
15+
{pattern: 'preserve commits', method: 'rebase'},
16+
],
17+
},
18+
claSignedLabel: 'cla: yes',
19+
mergeReadyLabel: /^action: merge(-assistance)?/,
20+
caretakerNoteLabel: /(action: merge-assistance)/,
21+
commitMessageFixupLabel: 'commit message fixup',
22+
// We can pick any of the NPM packages as we are in a monorepo where all packages are
23+
// published together with the same version and branching.
24+
labels: await getDefaultTargetLabelConfiguration(api, github, release),
25+
};
26+
};

.ng-dev/release.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ReleaseConfig } from '@angular/dev-infra-private/release/config';
2+
import { packages } from '../lib/packages';
3+
4+
/** Configuration for the `ng-dev release` command. */
5+
export const release: ReleaseConfig = {
6+
npmPackages: Object.keys(packages),
7+
// TODO: Set up package building.
8+
buildPackages: async () => [],
9+
// TODO: Set up generating changelogs
10+
generateReleaseNotesForHead: async () => {},
11+
};

docs/process/release.md

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,54 +29,15 @@ TBD
2929

3030
The list of PRs which are currently ready to merge (approved with passing status checks) can
3131
be found with [this search](https://github.com/angular/angular-cli/pulls?q=is%3Apr+is%3Aopen+label%3A%22PR+action%3A+merge%22+-is%3Adraft).
32-
This list should be checked daily and any ready PRs should be merged. For each
33-
PR, check the `PR target` label to understand where it should be merged to. If
34-
`master` is targetted, then click "Rebase and Merge". If the PR also targets a
35-
patch branch, see [Maintaining Patch Branches](#maintaining-patch-branches).
36-
Whatever the target, rebasing should be used over merging to avoid cluttering
37-
the Git history with merge commits.
38-
39-
### Maintaining Patch Branches
40-
41-
When a PR is merged, if the `PR target` label includes a branch other than
42-
`master`, commits will need to be cherry-picked to an associated branch. In
43-
particular, the `patch` target simply refers to the latest patch branch (eg.
44-
`1.2.x` or `1.3.x-rc.0`). This branch should be updated by cherry-picking all
45-
commits from the PR to it.
46-
47-
Cherry picking is done by checking out the patch branch and cherry picking the new commit onto it.
48-
The patch branch is simply named as a version number, with a X in the relevant spot, such as `9.0.x`.
49-
This should be done after merging to master.
50-
51-
```shell
52-
# Make sure commit to upstream/master is present in local repo.
53-
git fetch upstream master
54-
55-
# Check out patch branch from upstream.
56-
git fetch upstream <patch branch>
57-
git checkout <patch branch>
58-
59-
# Cherry pick the commit. Use the hash from the commit which was merged
60-
# into upstream/master, which should be known to your local repo.
61-
git cherry-pick -x <commit hash from master>
62-
# If you have multiple cherry picks, you can do them all here.
63-
64-
# Resolve merge conflicts if necessary...
65-
# Or abort and ask author to submit a separate commit targeting patch-only.
66-
67-
# Push changes.
68-
git push upstream <patch branch>
69-
```
32+
This list should be checked daily and any ready PRs should be merged. For each PR, check the
33+
`PR target` label to understand where it should be merged to. You can find which branches a specific
34+
PR will be merged into with the `yarn ng-dev pr check-target-branches <pr>` command.
7035

71-
If you get a `bad revision` error when cherry picking, make sure you are using
72-
the commit hash used when merged into `master`, _not_ the hash listed in the PR.
73-
Also verify that you have fetched `master` from `upstream` since that commit was
74-
merged.
36+
When ready to merge a PR, run the following command:
37+
```
38+
yarn ng-dev pr merge <pr>
39+
```
7540

76-
If the commit is not merged to `master` (because it targets `patch only` for
77-
instance), then you will need to fetch the contributor's branch for your local
78-
Git instance to have knowledge of the commit being cherry picked onto the patch
79-
branch.
8041

8142
### Maintaining LTS branches
8243

0 commit comments

Comments
 (0)