Skip to content

Commit

Permalink
fix: linked-versions + includeComponentInTag=false should work
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Nov 14, 2022
1 parent 7ebb59e commit 7794238
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion __snapshots__/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ exports['Manifest buildPullRequests should handle mixing componentless configs 1
---
<details><summary>1.0.1</summary>
<details><summary>pkg1: 1.0.1</summary>
## [1.0.1](https://github.com/fake-owner/fake-repo/compare/v1.0.0...v1.0.1) (1983-10-10)
Expand Down
2 changes: 1 addition & 1 deletion docs/manifest-releaser.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ Example:
},
{
"type": "linked-versions",
"group-name": "my group",
"groupName": "my group",
"components": [
"pkgA", "pkgB"
]
Expand Down
12 changes: 11 additions & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ export class Manifest {
continue;
}
const component = tagName.component || DEFAULT_COMPONENT_NAME;
const path = pathsByComponent[component];
const path =
pathsByComponent[component] || this.#getComponentlessPackage();
if (!path) {
this.logger.warn(
`Found release tag with component '${component}', but not configured in manifest`
Expand Down Expand Up @@ -747,6 +748,15 @@ export class Manifest {
);
}

#getComponentlessPackage(): string {
for (const path in this.repositoryConfig) {
if (!this.repositoryConfig[path].includeComponentInTag) {
return path;
}
}
return '';
}

private async backfillReleasesFromTags(
missingPaths: string[],
strategiesByPath: Record<string, Strategy>
Expand Down
3 changes: 0 additions & 3 deletions src/strategies/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ export abstract class BaseStrategy implements Strategy {
* @returns {string}
*/
async getComponent(): Promise<string | undefined> {
if (!this.includeComponentInTag) {
return '';
}
return this.component || (await this.getDefaultComponent());
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/release-notes/grouped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---


<details><summary>1.0.1</summary>
<details><summary>base: 1.0.1</summary>

## [1.0.1](https://github.com/testOwner/testRepo/compare/v1.0.0...v1.0.1) (2022-07-16)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:robot: I have created a release \*beep\* \*boop\*
---
<details><summary>3.2.0</summary>
<details><summary>@google-automation/bot-config-utils: 3.2.0</summary>


### Features
Expand Down
4 changes: 3 additions & 1 deletion test/util/pull-request-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ describe('PullRequestBody', () => {
expect(pullRequestBody).to.not.be.undefined;
const releaseData = pullRequestBody!.releaseData;
expect(releaseData).lengthOf(2);
expect(releaseData[0].component).to.be.undefined;
expect(releaseData[0].component).to.eq(
'@google-automation/bot-config-utils'
);
expect(releaseData[0].version?.toString()).to.eql('3.2.0');
expect(releaseData[0].notes).matches(/^### Features/);
expect(releaseData[1].component).to.eql(
Expand Down

0 comments on commit 7794238

Please sign in to comment.