Skip to content

Commit

Permalink
fix: draft-pull-requests config (#2241)
Browse files Browse the repository at this point in the history
I discovered this issue while using `release-please-action` which builds
a config via `Manifest.fromManifest`. In this function the
`draftPullRequest` setting from the config from the config defaults was
not considered when merging with the package specific configs. As a
result, defining this at the top level of the config had no impact.

Integration with the action was tested via a fork of the
`release-please-action` which was run on a test repo[3] the results can
be seen at[4]

Fixes: #1791

[1] https://github.com/google-github-actions/release-please-action/blob/a37ac6e4f6449ce8b3f7607e4d97d0146028dc0b/src/index.ts#L108
[2] matthewhughes934/release-please-action@07de5f3
[3] https://github.com/matthewhughes934/release-please-test/commit/c55af6660b7e67974ed4d9924e4a378c3ab01a7c
[4] https://github.com/matthewhughes934/release-please-test/pull/10

Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
matthewhughes934 and chingor13 authored Mar 13, 2024
1 parent 18c4571 commit 7028527
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,8 @@ function mergeReleaserConfig(
skipGithubRelease:
pathConfig.skipGithubRelease ?? defaultConfig.skipGithubRelease,
draft: pathConfig.draft ?? defaultConfig.draft,
draftPullRequest:
pathConfig.draftPullRequest ?? defaultConfig.draftPullRequest,
prerelease: pathConfig.prerelease ?? defaultConfig.prerelease,
component: pathConfig.component ?? defaultConfig.component,
packageName: pathConfig.packageName ?? defaultConfig.packageName,
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/manifest/config/draft-pull-request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"draft-pull-request": true,
"packages": {
".": {},
"node-packages": {
"draft-pull-request": false
}
}
}
28 changes: 28 additions & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,34 @@ describe('Manifest', () => {
}
);
});
it('should consider draft-pull-requests', async () => {
const getFileContentsStub = sandbox.stub(
github,
'getFileContentsOnBranch'
);
getFileContentsStub
.withArgs('release-please-config.json', 'main')
.resolves(
buildGitHubFileContent(
fixturesPath,
'manifest/config/draft-pull-request.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['.'].draftPullRequest).to.be.true;
expect(manifest.repositoryConfig['node-packages'].draftPullRequest).to.be
.false;
});
});

describe('fromConfig', () => {
Expand Down

0 comments on commit 7028527

Please sign in to comment.