Skip to content

Commit 8f1a3a8

Browse files
authored
fix: skip component when manifest release does not include component (#1537)
When a multi-component release PR was merged, we were rejecting untouched components only because we didn't find a version. However, if the group pull request title pattern was overridden and provided a version, we would not reject the release. Now, we reject components if we do not find release data for them in the pull request. Fixes #1527 Fixes #1536
1 parent fc0ac75 commit 8f1a3a8

3 files changed

Lines changed: 98 additions & 3 deletions

File tree

src/strategies/base.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,24 @@ export abstract class BaseStrategy implements Strategy {
488488
}
489489
releaseData = pullRequestBody.releaseData[0];
490490
} else {
491-
// manifest release with multiple components
492-
releaseData = pullRequestBody.releaseData.find(releaseData => {
491+
// manifest release with multiple components - find the release notes
492+
// for the component to see if it was included in this release (parsed
493+
// from the release pull request body)
494+
releaseData = pullRequestBody.releaseData.find(datum => {
493495
return (
494-
this.normalizeComponent(releaseData.component) ===
496+
this.normalizeComponent(datum.component) ===
495497
this.normalizeComponent(component)
496498
);
497499
});
500+
501+
if (!releaseData && pullRequestBody.releaseData.length > 0) {
502+
logger.info(
503+
`Pull request contains releases, but not for component: ${component}`
504+
);
505+
return;
506+
}
498507
}
508+
499509
const notes = releaseData?.notes;
500510
if (notes === undefined) {
501511
logger.warn('Failed to find release notes');
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
:robot: I have created a release *beep* *boop*
2+
---
3+
4+
5+
<details><summary>1.0.1</summary>
6+
7+
## [1.0.1](https://github.com/testOwner/testRepo/compare/v1.0.0...v1.0.1) (2022-07-16)
8+
9+
10+
### Bug Fixes
11+
12+
* **chat:** add missing ellipsis to start log message ([00a2995](https://github.com/testOwner/testRepo/commit/00a299552dcee16479b987043beadbf846097126))
13+
</details>
14+
15+
<details><summary>chat: 1.0.1</summary>
16+
17+
## [1.0.1](https://github.com/testOwner/testRepo/compare/chat-v1.0.0...chat-v1.0.1) (2022-07-16)
18+
19+
20+
### Bug Fixes
21+
22+
* **chat:** add missing ellipsis to start log message ([00a2995](https://github.com/testOwner/testRepo/commit/00a299552dcee16479b987043beadbf846097126))
23+
</details>
24+
25+
---
26+
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).

test/manifest.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,6 +4653,65 @@ describe('Manifest', () => {
46534653
expect(releases[0].notes).to.be.a('string');
46544654
expect(releases[0].path).to.eql('.');
46554655
});
4656+
4657+
it('should find the correct number of releases with a componentless tag', async () => {
4658+
mockPullRequests(
4659+
github,
4660+
[],
4661+
[
4662+
{
4663+
headBranchName: 'release-please--branches--main',
4664+
baseBranchName: 'main',
4665+
number: 2,
4666+
title: 'chore: release v1.0.1',
4667+
body: pullRequestBody('release-notes/grouped.txt'),
4668+
labels: ['autorelease: pending'],
4669+
files: [],
4670+
sha: 'abc123',
4671+
},
4672+
]
4673+
);
4674+
const manifest = new Manifest(
4675+
github,
4676+
'main',
4677+
{
4678+
'.': {
4679+
releaseType: 'simple',
4680+
pullRequestTitlePattern: 'chore: release v${version}',
4681+
component: 'base',
4682+
includeComponentInTag: false,
4683+
},
4684+
api: {
4685+
releaseType: 'simple',
4686+
component: 'api',
4687+
},
4688+
chat: {
4689+
releaseType: 'simple',
4690+
component: 'chat',
4691+
},
4692+
cmds: {
4693+
releaseType: 'simple',
4694+
component: 'cmds',
4695+
},
4696+
presence: {
4697+
releaseType: 'simple',
4698+
component: 'presence',
4699+
},
4700+
},
4701+
{
4702+
'.': Version.parse('1.0.0'),
4703+
api: Version.parse('1.0.0'),
4704+
chat: Version.parse('1.0.0'),
4705+
cmds: Version.parse('1.0.0'),
4706+
presence: Version.parse('1.0.0'),
4707+
},
4708+
{
4709+
groupPullRequestTitlePattern: 'chore: release v${version}',
4710+
}
4711+
);
4712+
const releases = await manifest.buildReleases();
4713+
expect(releases).lengthOf(2);
4714+
});
46564715
});
46574716

46584717
describe('createReleases', () => {

0 commit comments

Comments
 (0)