Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make workspace plugin with separate-pull-request fine #2310

Merged
59 changes: 0 additions & 59 deletions __snapshots__/php-manifest.js

This file was deleted.

51 changes: 51 additions & 0 deletions __snapshots__/separate-pull-requests-workspace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
exports['Plugin compatibility separate-pull-requests and workspace plugin should version bump dependencies together 1'] = `
:robot: I have created a release *beep* *boop*
---


## [1.0.1](https://github.com/fake-owner/fake-repo/compare/pkgA-v1.0.0...pkgA-v1.0.1) (1983-10-10)


### Dependencies

* The following workspace dependencies were updated
* dependencies
* pkgC bumped to 1.1.0

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['Plugin compatibility separate-pull-requests and workspace plugin should version bump dependencies together 2'] = `
:robot: I have created a release *beep* *boop*
---


## [1.0.1](https://github.com/fake-owner/fake-repo/compare/pkgB-v1.0.0...pkgB-v1.0.1) (1983-10-10)


### Dependencies

* The following workspace dependencies were updated
* dependencies
* pkgC bumped to 1.1.0

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['Plugin compatibility separate-pull-requests and workspace plugin should version bump dependencies together 3'] = `
:robot: I have created a release *beep* *boop*
---


## [1.1.0](https://github.com/fake-owner/fake-repo/compare/pkgC-v1.0.0...pkgC-v1.1.0) (1983-10-10)


### Features

* some feature ([aaaaaa](https://github.com/fake-owner/fake-repo/commit/aaaaaa))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`
15 changes: 15 additions & 0 deletions src/factories/plugin-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface PluginFactoryOptions {
targetBranch: string;
repositoryConfig: RepositoryConfig;
manifestPath: string;
separatePullRequests?: boolean;

// node options
alwaysLinkLocal?: boolean;
Expand All @@ -54,6 +55,8 @@ export type PluginBuilder = (options: PluginFactoryOptions) => ManifestPlugin;

const pluginFactories: Record<string, PluginBuilder> = {
'linked-versions': options =>
// NOTE: linked-versions had already have a different behavior about merging
// see test/plugins/compatibility/linked-versions-workspace.ts
new LinkedVersions(
options.github,
options.targetBranch,
Expand All @@ -73,6 +76,9 @@ const pluginFactories: Record<string, PluginBuilder> = {
{
...options,
...(options.type as WorkspacePluginOptions),
merge:
(options.type as WorkspacePluginOptions).merge ??
!options.separatePullRequests,
}
),
'node-workspace': options =>
Expand All @@ -83,6 +89,9 @@ const pluginFactories: Record<string, PluginBuilder> = {
{
...options,
...(options.type as WorkspacePluginOptions),
merge:
(options.type as WorkspacePluginOptions).merge ??
!options.separatePullRequests,
}
),
'maven-workspace': options =>
Expand All @@ -93,6 +102,9 @@ const pluginFactories: Record<string, PluginBuilder> = {
{
...options,
...(options.type as WorkspacePluginOptions),
merge:
(options.type as WorkspacePluginOptions).merge ??
!options.separatePullRequests,
}
),
'sentence-case': options =>
Expand All @@ -112,6 +124,9 @@ const pluginFactories: Record<string, PluginBuilder> = {
};

export function buildPlugin(options: PluginFactoryOptions): ManifestPlugin {
if (!options.separatePullRequests) {
options.separatePullRequests = false;
}
if (typeof options.type === 'object') {
const builder = pluginFactories[options.type.type];
if (builder) {
Expand Down
1 change: 1 addition & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export class Manifest {
targetBranch: this.targetBranch,
repositoryConfig: this.repositoryConfig,
manifestPath: this.manifestPath,
separatePullRequests: this.separatePullRequests,
})
);
this.pullRequestOverflowHandler = new FilePullRequestOverflowHandler(
Expand Down
6 changes: 6 additions & 0 deletions test/factories/plugin-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('PluginFactory', () => {
targetBranch: 'target-branch',
repositoryConfig,
manifestPath: '.manifest.json',
separatePullRequests: false,
});
expect(plugin).to.not.be.undefined;
});
Expand All @@ -66,6 +67,7 @@ describe('PluginFactory', () => {
targetBranch: 'target-branch',
repositoryConfig,
manifestPath: '.manifest.json',
separatePullRequests: false,
})
).to.throw();
});
Expand All @@ -80,6 +82,7 @@ describe('PluginFactory', () => {
targetBranch: 'target-branch',
repositoryConfig,
manifestPath: '.manifest.json',
separatePullRequests: false,
});
expect(plugin).to.not.be.undefined;
expect(plugin).instanceof(LinkedVersions);
Expand All @@ -94,6 +97,7 @@ describe('PluginFactory', () => {
targetBranch: 'target-branch',
repositoryConfig,
manifestPath: '.manifest.json',
separatePullRequests: false,
});
expect(plugin).to.not.be.undefined;
expect(plugin).instanceof(GroupPriority);
Expand All @@ -108,6 +112,7 @@ describe('PluginFactory', () => {
targetBranch: 'target-branch',
repositoryConfig,
manifestPath: '.manifest.json',
separatePullRequests: false,
});
expect(plugin).to.not.be.undefined;
expect(plugin).instanceof(NodeWorkspace);
Expand Down Expand Up @@ -151,6 +156,7 @@ describe('PluginFactory', () => {
repositoryConfig: {},
targetBranch: 'main',
manifestPath: '.manifest.json',
separatePullRequests: false,
};
const strategy = await buildPlugin(pluginOptions);
expect(strategy).to.be.instanceof(CustomTest);
Expand Down
Loading
Loading