diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 05b089229ac6f70049745eee036ac65b8fe37ba7..b57364434347c706b402a7a130d034a2819e14bf 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2736,6 +2736,14 @@ Here's an example of how you would define PR priority so that devDependencies ar The PR title is important for some of Renovate's matching algorithms (e.g. determining whether to recreate a PR or not) so ideally don't modify it much. +## prTitleStrict + +There are certain scenarios where the default behavior appends extra context to the PR title. + +These scenarios include if a `baseBranch` or if there is a grouped update and either `separateMajorMinor` or `separateMinorPatch` is true. + +Using this option allows you to skip these default behaviors and use other templating methods to control the format of the PR title. + ## printConfig This option is useful for troubleshooting, particularly if using presets. diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 698a17056860c8f4814f20b323af91ee42add6ca..76a7881dd40fe72a4a06226cd579ecc20e2d74a3 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1855,6 +1855,15 @@ const options: RenovateOptions[] = [ default: null, cli: false, }, + { + name: 'prTitleStrict', + description: + 'Whether to bypass appending extra context to the Pull Request title.', + type: 'boolean', + experimental: true, + default: false, + cli: false, + }, { name: 'prHeader', description: 'Text added here will be placed first in the PR body.', diff --git a/lib/workers/repository/updates/generate.spec.ts b/lib/workers/repository/updates/generate.spec.ts index 040726a9034f8e7bf320d66e1cfd71e6fe4bca99..c44d2e74ee6cf5263f22ae1ca6edb18900e82ab8 100644 --- a/lib/workers/repository/updates/generate.spec.ts +++ b/lib/workers/repository/updates/generate.spec.ts @@ -357,6 +357,61 @@ describe('workers/repository/updates/generate', () => { expect(res.recreateClosed).toBeTrue(); }); + it('skips appending baseBranch and updateType to prTitle when prTitleStrict is true', () => { + const branch = [ + { + manager: 'some-manager', + depName: 'depB', + groupName: 'some-group', + branchName: 'some-branch', + commitMessage: + '{{{groupName}}} {{{commitMessageExtra}}} {{{commitMessageSuffix}}}', + commitMessageExtra: + 'to {{#if isMajor}}{{prettyNewMajor}}{{else}}{{prettyNewVersion}}{{/if}}', + foo: 1, + newValue: '5.1.2', + newVersion: '5.1.2', + group: { + foo: 2, + }, + releaseTimestamp: '2017-02-07T20:01:41+00:00', + updateType: 'minor', + separateMinorPatch: true, + prTitleStrict: true, + }, + { + manager: 'some-manager', + depName: 'depA', + groupName: 'some-group', + branchName: 'some-branch', + commitMessage: + '{{{groupName}}} {{{commitMessageExtra}}} {{{commitMessageSuffix}}}', + commitMessageExtra: + 'to {{#if isMajor}}{{prettyNewMajor}}{{else}}{{prettyNewVersion}}{{/if}}', + foo: 1, + newValue: '1.1.0', + newVersion: '1.1.0', + group: { + foo: 2, + }, + releaseTimestamp: '2017-02-08T20:01:41+00:00', + updateType: 'minor', + separateMinorPatch: true, + prTitleStrict: true, + }, + ] satisfies BranchUpgradeConfig[]; + const res = generateBranchConfig(branch); + expect(res).toMatchObject({ + foo: 2, + isGroup: true, + recreateClosed: true, + prTitle: 'some-group', + commitMessage: 'some-group', + groupName: 'some-group', + releaseTimestamp: '2017-02-08T20:01:41+00:00', + }); + }); + it('groups multiple upgrades different version', () => { const branch = [ { diff --git a/lib/workers/repository/updates/generate.ts b/lib/workers/repository/updates/generate.ts index 5a3ff3e05be0621e09e5aacc650f3e7bf60d8ab1..3dd6b922615837d692b025fa5b0fcb8c558f00eb 100644 --- a/lib/workers/repository/updates/generate.ts +++ b/lib/workers/repository/updates/generate.ts @@ -255,20 +255,22 @@ export function generateBranchConfig( } else { [upgrade.prTitle] = upgrade.commitMessage.split(newlineRegex); } - upgrade.prTitle += upgrade.hasBaseBranches ? ' ({{baseBranch}})' : ''; - if (upgrade.isGroup) { - upgrade.prTitle += - upgrade.updateType === 'major' && upgrade.separateMajorMinor - ? ' (major)' - : ''; - upgrade.prTitle += - upgrade.updateType === 'minor' && upgrade.separateMinorPatch - ? ' (minor)' - : ''; - upgrade.prTitle += - upgrade.updateType === 'patch' && upgrade.separateMinorPatch - ? ' (patch)' - : ''; + if (!upgrade.prTitleStrict) { + upgrade.prTitle += upgrade.hasBaseBranches ? ' ({{baseBranch}})' : ''; + if (upgrade.isGroup) { + upgrade.prTitle += + upgrade.updateType === 'major' && upgrade.separateMajorMinor + ? ' (major)' + : ''; + upgrade.prTitle += + upgrade.updateType === 'minor' && upgrade.separateMinorPatch + ? ' (minor)' + : ''; + upgrade.prTitle += + upgrade.updateType === 'patch' && upgrade.separateMinorPatch + ? ' (patch)' + : ''; + } } // Compile again to allow for nested templates upgrade.prTitle = template.compile(upgrade.prTitle, upgrade); diff --git a/lib/workers/types.ts b/lib/workers/types.ts index 7b53bcddb2747ce7a06144d5b63c227cbee30b54..8357d49264a75a7ae1fd4544f79f6f7617c8d682 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -56,6 +56,7 @@ export interface BranchUpgradeConfig prBodyTemplate?: string; prPriority?: number; prTitle?: string; + prTitleStrict?: boolean; prettyNewMajor?: string; prettyNewVersion?: string; releases?: ReleaseWithNotes[];