-
Notifications
You must be signed in to change notification settings - Fork 370
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
Changes from 7 commits
a5209ad
f6082f3
a944b75
b2d4b10
8bfda16
f447a63
9092b4b
eb0b59c
90e796f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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). | ||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import { | |
RepositoryConfig, | ||
SentenceCasePluginConfig, | ||
GroupPriorityPluginConfig, | ||
WorkspacePluginConfig, | ||
} from '../manifest'; | ||
import {GitHub} from '../github'; | ||
import {ManifestPlugin} from '../plugin'; | ||
|
@@ -38,6 +39,7 @@ export interface PluginFactoryOptions { | |
targetBranch: string; | ||
repositoryConfig: RepositoryConfig; | ||
manifestPath: string; | ||
separatePullRequests: boolean; | ||
|
||
// node options | ||
alwaysLinkLocal?: boolean; | ||
|
@@ -63,6 +65,7 @@ const pluginFactories: Record<string, PluginBuilder> = { | |
{ | ||
...options, | ||
...(options.type as WorkspacePluginOptions), | ||
merge: determineMerge(options), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will override the Also, it seems weird for |
||
} | ||
), | ||
'cargo-workspace': options => | ||
|
@@ -73,6 +76,7 @@ const pluginFactories: Record<string, PluginBuilder> = { | |
{ | ||
...options, | ||
...(options.type as WorkspacePluginOptions), | ||
merge: determineMerge(options), | ||
} | ||
), | ||
'node-workspace': options => | ||
|
@@ -83,6 +87,7 @@ const pluginFactories: Record<string, PluginBuilder> = { | |
{ | ||
...options, | ||
...(options.type as WorkspacePluginOptions), | ||
merge: determineMerge(options), | ||
} | ||
), | ||
'maven-workspace': options => | ||
|
@@ -93,6 +98,7 @@ const pluginFactories: Record<string, PluginBuilder> = { | |
{ | ||
...options, | ||
...(options.type as WorkspacePluginOptions), | ||
merge: determineMerge(options), | ||
} | ||
), | ||
'sentence-case': options => | ||
|
@@ -149,3 +155,24 @@ export function unregisterPlugin(name: string) { | |
export function getPluginTypes(): readonly VersioningStrategyType[] { | ||
return Object.keys(pluginFactories).sort(); | ||
} | ||
|
||
export function determineMerge( | ||
options: PluginFactoryOptions | ||
): boolean | undefined { | ||
// NOTE: linked-versions had already have a different behavior when this code wrote | ||
// see test/plugins/compatibility/linked-versions-workspace.ts | ||
if (typeof options.type === 'string' && options.type !== 'linked-versions') { | ||
return !options.separatePullRequests; | ||
} | ||
if (typeof options.type !== 'string') { | ||
const type = options.type as | ||
| LinkedVersionPluginConfig | ||
| WorkspacePluginConfig; | ||
if (typeof type.merge === 'undefined' && type.type !== 'linked-versions') { | ||
return !options.separatePullRequests; | ||
} | ||
return type.merge; | ||
} | ||
// return undefined due to relying on the default behavior of the plugin constructor | ||
return undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be optional and have a default value. The ability to register plugins and pluginFactories is part of the public API (
PluginFactoryOptions
). It's unlikely that someone is providing their ownPluginFactoryOptions
instance, but a default wouldn't hurt.