From 452f084ef8f664830c560472802e5942804df02d Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 30 Jun 2022 12:57:08 -0700 Subject: [PATCH] fix: correctly parse the changelog-type from the manifest config (#1498) * test: failing test for parsing changelog-type from manifest * fix: correctly parse the changelog-type from the manifest config --- src/manifest.ts | 1 + .../manifest/config/changelog-type.json | 13 ++++++++ test/manifest.ts | 30 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 test/fixtures/manifest/config/changelog-type.json diff --git a/src/manifest.ts b/src/manifest.ts index d9cb00178..8af6d887e 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -1471,6 +1471,7 @@ function mergeReleaserConfig( pathConfig.changelogSections ?? defaultConfig.changelogSections, changelogPath: pathConfig.changelogPath ?? defaultConfig.changelogPath, changelogHost: pathConfig.changelogHost ?? defaultConfig.changelogHost, + changelogType: pathConfig.changelogType ?? defaultConfig.changelogType, releaseAs: pathConfig.releaseAs ?? defaultConfig.releaseAs, skipGithubRelease: pathConfig.skipGithubRelease ?? defaultConfig.skipGithubRelease, diff --git a/test/fixtures/manifest/config/changelog-type.json b/test/fixtures/manifest/config/changelog-type.json new file mode 100644 index 000000000..06452ef23 --- /dev/null +++ b/test/fixtures/manifest/config/changelog-type.json @@ -0,0 +1,13 @@ +{ + "release-type": "simple", + "changelog-type": "github", + "packages": { + ".": { + "component": "root" + }, + "packages/bot-config-utils": { + "component": "bot-config-utils", + "changelog-type": "default" + } + } +} diff --git a/test/manifest.ts b/test/manifest.ts index 19f9694f2..5f8520eb4 100644 --- a/test/manifest.ts +++ b/test/manifest.ts @@ -592,6 +592,36 @@ describe('Manifest', () => { ).to.eql('https://override.example.com'); }); + it('should read changelog type from manifest', async () => { + const getFileContentsStub = sandbox.stub( + github, + 'getFileContentsOnBranch' + ); + getFileContentsStub + .withArgs('release-please-config.json', 'main') + .resolves( + buildGitHubFileContent( + fixturesPath, + 'manifest/config/changelog-type.json' + ) + ) + .withArgs('.release-please-manifest.json', 'main') + .resolves( + buildGitHubFileContent( + fixturesPath, + 'manifest/versions/versions.json' + ) + ); + const manifest = await Manifest.fromManifest( + github, + github.repository.defaultBranch + ); + expect(manifest.repositoryConfig['.'].changelogType).to.eql('github'); + expect( + manifest.repositoryConfig['packages/bot-config-utils'].changelogType + ).to.eql('default'); + }); + it('should throw a configuration error for a missing manifest config', async () => { const getFileContentsStub = sandbox.stub( github,