Skip to content

Commit

Permalink
fix: release tagging can find branch components (googleapis#1425)
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 authored May 10, 2022
1 parent 534f425 commit 2947d1e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/strategies/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,14 @@ export abstract class BaseStrategy implements Strategy {
pullRequestBody.releaseData.length === 1 &&
!pullRequestBody.releaseData[0].component
) {
const branchComponent = await this.getBranchComponent();
// standalone release PR, ensure the components match
if (
this.normalizeComponent(branchName.component) !==
this.normalizeComponent(component)
this.normalizeComponent(branchComponent)
) {
logger.warn(
`PR component: ${branchName.component} does not match configured component: ${component}`
`PR component: ${branchName.component} does not match configured component: ${branchComponent}`
);
return;
}
Expand Down
49 changes: 47 additions & 2 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3888,7 +3888,49 @@ describe('Manifest', () => {
[],
[
{
headBranchName: 'release-please/branches/main',
headBranchName: 'release-please--branches--main',
baseBranchName: 'main',
number: 1234,
title: 'chore(main): release 3.2.7',
body: pullRequestBody('release-notes/single.txt'),
labels: ['autorelease: pending'],
files: [],
sha: 'abc123',
},
]
);
const manifest = new Manifest(
github,
'main',
{
'.': {
releaseType: 'simple',
},
},
{
'.': Version.parse('3.2.6'),
}
);
const releases = await manifest.buildReleases();
expect(releases).lengthOf(1);
expect(releases[0].tag.toString()).to.eql('v3.2.7');
expect(releases[0].sha).to.eql('abc123');
expect(releases[0].notes)
.to.be.a('string')
.and.satisfy((msg: string) => msg.startsWith('### [3.2.7]'));
expect(releases[0].path).to.eql('.');
expect(releases[0].name).to.eql('v3.2.7');
expect(releases[0].draft).to.be.undefined;
expect(releases[0].prerelease).to.be.undefined;
});

it('should handle a single component release', async () => {
mockPullRequests(
github,
[],
[
{
headBranchName: 'release-please--branches--main--components--foo',
baseBranchName: 'main',
number: 1234,
title: 'chore(main): release 3.2.7',
Expand All @@ -3905,6 +3947,8 @@ describe('Manifest', () => {
{
'.': {
releaseType: 'simple',
component: 'foo',
includeComponentInTag: false,
},
},
{
Expand Down Expand Up @@ -4276,7 +4320,8 @@ describe('Manifest', () => {
[],
[
{
headBranchName: 'release-please/branches/main',
headBranchName:
'release-please--branches--main--components--release-brancher',
baseBranchName: 'main',
number: 1234,
title: 'chore(main): release v1.3.1',
Expand Down

0 comments on commit 2947d1e

Please sign in to comment.