Skip to content

Commit

Permalink
fix: combined manifest PR should include labels (#1137)
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 committed Dec 1, 2021
1 parent 328009d commit d8bb7ca
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
19 changes: 19 additions & 0 deletions __snapshots__/merge.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
exports['Merge plugin run merges all labels for pull requests 1'] = `
:robot: I have created a release *beep* *boop*
---
<details><summary>python-pkg: 1.0.0</summary>
Release notes for path: python, releaseType: python
</details>
<details><summary>@here/pkgA: 3.3.4</summary>
Release notes for path: node, releaseType: node
</details>
---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['Merge plugin run merges multiple pull requests as a draft 1'] = `
:robot: I have created a release *beep* *boop*
---
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export class Merge extends ManifestPlugin {
updatesByPath[update.path] = [update];
}
}
for (const label of pullRequest.labels) {
labels.add(label);
}
releaseData.push(...pullRequest.body.releaseData);
}

Expand Down
5 changes: 3 additions & 2 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export function buildMockCandidatePullRequest(
component?: string,
updates: Update[] = [],
notes?: string,
draft?: boolean
draft?: boolean,
labels: string[] = []
): CandidateReleasePullRequest {
const version = Version.parse(versionString);
return {
Expand All @@ -287,7 +288,7 @@ export function buildMockCandidatePullRequest(
},
]),
updates,
labels: [],
labels,
headRefName: BranchName.ofTargetBranch('main').toString(),
version,
draft: draft ?? false,
Expand Down
1 change: 1 addition & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ describe('Manifest', () => {
);
const pullRequests = await manifest.buildPullRequests();
expect(pullRequests).lengthOf(1);
expect(pullRequests[0].labels).to.eql(['autorelease: pending']);
snapshot(dateSafe(pullRequests[0].body.toString()));
});

Expand Down
53 changes: 53 additions & 0 deletions test/plugins/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,58 @@ describe('Merge plugin', () => {
snapshot(dateSafe(candidate!.pullRequest.body.toString()));
expect(candidate.pullRequest.draft).to.be.true;
});

it('merges all labels for pull requests', async () => {
const candidates: CandidateReleasePullRequest[] = [
buildMockCandidatePullRequest(
'python',
'python',
'1.0.0',
'python-pkg',
[
{
path: 'path1/foo',
createIfMissing: false,
updater: new RawContent('foo'),
},
],
undefined,
undefined,
['label-a', 'label-b']
),
buildMockCandidatePullRequest(
'node',
'node',
'3.3.4',
'@here/pkgA',
[
{
path: 'path1/foo',
createIfMissing: false,
updater: new RawContent('bar'),
},
{
path: 'path2/foo',
createIfMissing: false,
updater: new RawContent('asdf'),
},
],
undefined,
undefined,
['label-a', 'label-c']
),
];
const plugin = new Merge(github, 'main', {});
const newCandidates = await plugin.run(candidates);
expect(newCandidates).lengthOf(1);
const candidate = newCandidates[0]!;
expect(candidate.pullRequest.labels).lengthOf(3);
expect(candidate.pullRequest.labels).to.eql([
'label-a',
'label-b',
'label-c',
]);
snapshot(dateSafe(candidate.pullRequest.body.toString()));
});
});
});

0 comments on commit d8bb7ca

Please sign in to comment.