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

feat: separateMultipleMinor #24538

Merged
merged 35 commits into from Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
953341b
update docs
phyzical Sep 20, 2023
c15c836
support multiple minor pull requests
phyzical Sep 20, 2023
b152f12
support group
phyzical Sep 20, 2023
323a247
update the branch name via replace on .x instead
phyzical Sep 20, 2023
f672f8f
Update lib/config/options/index.ts
rarkins Sep 27, 2023
1a47f8f
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Sep 27, 2023
ed3d00c
Update lib/workers/repository/updates/branch-name.ts
rarkins Sep 27, 2023
bf4c026
Update docs/usage/configuration-options.md
rarkins Sep 28, 2023
cc4c600
Apply suggestions from code review
rarkins Sep 28, 2023
66a3fb6
Update lib/workers/repository/updates/branch-name.spec.ts
phyzical Oct 5, 2023
b2c0217
Update lib/workers/repository/updates/branch-name.spec.ts
phyzical Oct 5, 2023
43c12d2
Update lib/workers/repository/updates/branch-name.spec.ts
phyzical Oct 5, 2023
09a4a36
Merge branch 'main' into feature/seperateMultipleMinor
phyzical Oct 5, 2023
b9e79d5
lint
phyzical Oct 5, 2023
f5c78da
Update lib/config/presets/internal/default.ts
phyzical Oct 6, 2023
83af299
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Oct 23, 2023
45aba59
Update docs/usage/configuration-options.md
phyzical Oct 27, 2023
0aadc2c
Update docs/usage/configuration-options.md
phyzical Oct 27, 2023
b5b40f0
Update lib/config/options/index.ts
phyzical Oct 27, 2023
ac0ce96
Update lib/workers/repository/updates/branch-name.ts
phyzical Oct 27, 2023
a0463f7
Update docs/usage/configuration-options.md
phyzical Oct 27, 2023
6d7912b
Merge branch 'main' into feature/seperateMultipleMinor
phyzical Oct 27, 2023
af29f33
fix test
phyzical Oct 27, 2023
44bb571
Apply suggestions from code review
rarkins Nov 10, 2023
1d9b8af
Merge branch 'main' into feature/seperateMultipleMinor
phyzical Feb 6, 2024
e941623
eslint
phyzical Feb 6, 2024
8569589
md lint
phyzical Feb 6, 2024
1b3ec85
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Feb 19, 2024
9ff90aa
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Feb 19, 2024
e11953a
fix test
rarkins Feb 19, 2024
b9f17dd
Apply suggestions from code review
rarkins Mar 4, 2024
27e9e9f
Update lib/workers/repository/updates/branch-name.ts
viceice Mar 16, 2024
ac1cd26
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Mar 18, 2024
cd315d8
String
rarkins Mar 18, 2024
032bbbe
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Mar 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/usage/configuration-options.md
Expand Up @@ -3528,6 +3528,12 @@ Configure this to `true` if you wish to get one PR for every separate major vers
e.g. if you are on webpack@v1 currently then default behavior is a PR for upgrading to webpack@v3 and not for webpack@v2.
If this setting is true then you would get one PR for webpack@v2 and one for webpack@v3.

## separateMultipleMinor

Configure this to `true` if you wish to get one PR for every separate minor version upgrade of a dependency.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
e.g. if you are on webpack@v3.0.0 currently then default behavior is a PR for upgrading to webpack@v3.4.0 and not for webpack@v3.3.0, webpack@v3.2.0 and webpack@v3.1.0
If this setting is true then you would get one PR for webpack@v3.4.0, webpack@v3.3.0, webpack@v3.2.0 and webpack@v3.1.0
rarkins marked this conversation as resolved.
Show resolved Hide resolved

## stopUpdatingLabel

This feature only works on supported platforms, check the table above.
Expand Down
8 changes: 8 additions & 0 deletions lib/config/options/index.ts
Expand Up @@ -1442,6 +1442,14 @@ const options: RenovateOptions[] = [
type: 'boolean',
default: false,
},
{
name: 'separateMultipleMinor',
description:
'If set to `true`, PRs will be raised separately for each available `minor` upgrade version.',
phyzical marked this conversation as resolved.
Show resolved Hide resolved
stage: 'package',
type: 'boolean',
default: false,
rarkins marked this conversation as resolved.
Show resolved Hide resolved
},
{
name: 'separateMinorPatch',
description:
Expand Down
6 changes: 6 additions & 0 deletions lib/config/presets/internal/default.ts
Expand Up @@ -586,6 +586,12 @@ export const presets: Record<string, Preset> = {
separateMajorMinor: true,
separateMultipleMajor: true,
},
separateMultipleMinorReleases: {
description:
'Separate each `minor` version of dependencies into individual branches/PRs.',
separateMinorPatch: true,
phyzical marked this conversation as resolved.
Show resolved Hide resolved
separateMultipleMinor: true,
rarkins marked this conversation as resolved.
Show resolved Hide resolved
},
separatePatchReleases: {
description:
'Separate `patch` and `minor` releases of dependencies into separate PRs.',
Expand Down
1 change: 1 addition & 0 deletions lib/config/validation.ts
Expand Up @@ -382,6 +382,7 @@ export async function validateConfig(
'separateMajorMinor',
'separateMinorPatch',
'separateMultipleMajor',
'separateMultipleMinor',
'versioning',
];
if (is.nonEmptyArray(resolvedRule.matchUpdateTypes)) {
Expand Down
11 changes: 7 additions & 4 deletions lib/workers/repository/process/lookup/bucket.ts
Expand Up @@ -3,6 +3,7 @@ import type { VersioningApi } from '../../../../modules/versioning/types';
export interface BucketConfig {
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
separateMultipleMinor?: boolean;
separateMinorPatch?: boolean;
}

Expand All @@ -12,8 +13,12 @@ export function getBucket(
newVersion: string,
versioning: VersioningApi
): string | null {
const { separateMajorMinor, separateMultipleMajor, separateMinorPatch } =
config;
const {
separateMajorMinor,
separateMultipleMajor,
separateMultipleMinor,
separateMinorPatch,
} = config;
if (!separateMajorMinor) {
return 'latest';
}
Expand Down Expand Up @@ -46,11 +51,9 @@ export function getBucket(

// Check the minor update type first
if (fromMinor !== toMinor) {
/* future option
if (separateMultipleMinor) {
return `v${toMajor}.${toMinor}`;
}
*/

if (separateMinorPatch) {
return 'minor';
Expand Down
13 changes: 13 additions & 0 deletions lib/workers/repository/process/lookup/index.spec.ts
Expand Up @@ -1384,6 +1384,19 @@ describe('workers/repository/process/lookup/index', () => {
expect(res.updates).toHaveLength(3);
});

it('should upgrade to 16 minors', async () => {
config.currentValue = '1.0.0';
config.separateMultipleMinor = true;
config.packageName = 'webpack';
config.datasource = NpmDatasource.id;
httpMock
.scope('https://registry.npmjs.org')
.get('/webpack')
.reply(200, webpackJson);
const res = await lookup.lookupUpdates(config);
expect(res.updates).toHaveLength(16);
});

it('does not jump major unstable', async () => {
config.currentValue = '^4.4.0-canary.3';
config.rangeStrategy = 'replace';
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/process/lookup/types.ts
Expand Up @@ -41,6 +41,7 @@ export interface LookupUpdateConfig
isVulnerabilityAlert?: boolean;
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
separateMultipleMinor?: boolean;
datasource: string;
packageName: string;
minimumConfidence?: MergeConfidence | undefined;
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/process/lookup/update-type.ts
Expand Up @@ -4,6 +4,7 @@ import type * as allVersioning from '../../../../modules/versioning';
export interface UpdateTypeConfig {
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
separateMultipleMinor?: boolean;
separateMinorPatch?: boolean;
}

Expand Down
40 changes: 38 additions & 2 deletions lib/workers/repository/updates/branch-name.spec.ts
Expand Up @@ -45,6 +45,42 @@ describe('workers/repository/updates/branch-name', () => {
expect(upgrade.branchName).toBe('major-2-some-group-slug-grouptopic');
});

it('separates minor with groups', () => {
const upgrade: RenovateConfig = {
groupName: 'some group name',
groupSlug: 'some group slug',
updateType: 'minor',
separateMultipleMinor: true,
newMinor: 2.1,
group: {
branchName: '{{groupSlug}}-{{branchTopic}}',
branchTopic: 'grouptopic',
},
};
generateBranchName(upgrade);
expect(upgrade.branchName).toBe('minor-2.1-some-group-slug-grouptopic');
});

it('separates minor when separateMultipleMinor=true', () => {
const upgrade: RenovateConfig = {
branchName:
'{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}',
branchPrefix: 'renovate/',
additionalBranchPrefix: '',
depNameSanitized: 'lodash',
newMajor: 4,
separateMinorPatch: true,
isPatch: true,
newMinor: 17,
branchTopic:
'{{{depNameSanitized}}}-{{{newMajor}}}{{#if separateMultipleMinor}}{{#if isMinor}}.{{{newMinor}}}{{/if}}{{else}}{{#if separateMinorPatch}}{{#if isPatch}}.{{{newMinor}}}{{/if}}{{/if}}.x{{#if isLockfileUpdate}}-lockfile{{/if}}{{/if}}',
phyzical marked this conversation as resolved.
Show resolved Hide resolved
depName: 'dep',
group: {},
};
generateBranchName(upgrade);
expect(upgrade.branchName).toBe('renovate/lodash-4.17.x');
});

it('uses single major with groups', () => {
const upgrade: RenovateConfig = {
groupName: 'some group name',
Expand Down Expand Up @@ -103,7 +139,7 @@ describe('workers/repository/updates/branch-name', () => {
isPatch: true,
newMinor: 17,
branchTopic:
'{{{depNameSanitized}}}-{{{newMajor}}}{{#if separateMinorPatch}}{{#if isPatch}}.{{{newMinor}}}{{/if}}{{/if}}.x{{#if isLockfileUpdate}}-lockfile{{/if}}',
'{{{depNameSanitized}}}-{{{newMajor}}}{{#if separateMultipleMinor}}{{#if isMinor}}.{{{newMinor}}}{{/if}}{{else}}{{#if separateMinorPatch}}{{#if isPatch}}.{{{newMinor}}}{{/if}}{{/if}}.x{{#if isLockfileUpdate}}-lockfile{{/if}}{{/if}}',
phyzical marked this conversation as resolved.
Show resolved Hide resolved
depName: 'dep',
group: {},
};
Expand All @@ -123,7 +159,7 @@ describe('workers/repository/updates/branch-name', () => {
isPatch: true,
newMinor: 17,
branchTopic:
'{{{depNameSanitized}}}-{{{newMajor}}}{{#if separateMinorPatch}}{{#if isPatch}}.{{{newMinor}}}{{/if}}{{/if}}.x{{#if isLockfileUpdate}}-lockfile{{/if}}',
'{{{depNameSanitized}}}-{{{newMajor}}}{{#if separateMultipleMinor}}{{#if isMinor}}.{{{newMinor}}}{{/if}}{{else}}{{#if separateMinorPatch}}{{#if isPatch}}.{{{newMinor}}}{{/if}}{{/if}}.x{{#if isLockfileUpdate}}-lockfile{{/if}}{{/if}}',
phyzical marked this conversation as resolved.
Show resolved Hide resolved
depName: 'dep',
group: {},
};
Expand Down
10 changes: 9 additions & 1 deletion lib/workers/repository/updates/branch-name.ts
Expand Up @@ -64,6 +64,10 @@ export function generateBranchName(update: RenovateConfig): void {
update.groupSlug = `major-${update.groupSlug}`;
}
}
if (update.updateType === 'minor' && update.separateMultipleMinor) {
const newMinor = String(update.newMinor);
update.groupSlug = `minor-${newMinor}-${update.groupSlug}`;
phyzical marked this conversation as resolved.
Show resolved Hide resolved
}
rarkins marked this conversation as resolved.
Show resolved Hide resolved
if (update.updateType === 'patch' && update.separateMinorPatch) {
update.groupSlug = `patch-${update.groupSlug}`;
}
Expand Down Expand Up @@ -110,7 +114,11 @@ export function generateBranchName(update: RenovateConfig): void {
update.branchName = template.compile(update.branchName, update);
update.branchName = template.compile(update.branchName, update);
}

if (update.updateType === 'minor' && update.separateMultipleMinor) {
const newMinor = String(update.newMinor);
update.branchName = update.branchName.replace('.x', `.${newMinor}.x`);
rarkins marked this conversation as resolved.
Show resolved Hide resolved
logger.info(update.branchName);
rarkins marked this conversation as resolved.
Show resolved Hide resolved
rarkins marked this conversation as resolved.
Show resolved Hide resolved
rarkins marked this conversation as resolved.
Show resolved Hide resolved
}
update.branchName = cleanBranchName(
update.branchName,
update.branchNameStrict
Expand Down