diff --git a/lib/config/__snapshots__/migration.spec.ts.snap b/lib/config/__snapshots__/migration.spec.ts.snap index 35860a317c26e18b13a98fa9077f377edb6f2ec5..5f313623084b535087619294ba13fdb159ec64b8 100644 --- a/lib/config/__snapshots__/migration.spec.ts.snap +++ b/lib/config/__snapshots__/migration.spec.ts.snap @@ -6,6 +6,51 @@ Object { } `; +exports[`config/migration migrateConfig(config, parentConfig) it migrates packageRules 1`] = ` +Object { + "packageRules": Array [ + Object { + "excludePackageNames": Array [ + "baz", + ], + "excludePackagePatterns": Array [ + "^baz", + ], + "matchBaseBranches": Array [ + "master", + ], + "matchDatasources": Array [ + "orb", + ], + "matchDepTypes": Array [ + "peerDependencies", + ], + "matchLanguages": Array [ + "python", + ], + "matchManagers": Array [ + "dockerfile", + ], + "matchPackageNames": Array [ + "foo", + ], + "matchPackagePatterns": Array [ + "^bar", + ], + "matchPaths": Array [ + "package.json", + ], + "matchSourceUrlPrefixes": Array [ + "https://github.com/vuejs/vue", + ], + "matchUpdateTypes": Array [ + "major", + ], + }, + ], +} +`; + exports[`config/migration migrateConfig(config, parentConfig) migrates before and after schedules 1`] = ` Object { "major": Object { @@ -39,6 +84,7 @@ Object { "baseBranches": Array [ "next", ], + "branchName": "{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}", "branchPrefix": "renovate/", "commitMessage": "{{#if semanticCommitType}}{{semanticCommitType}}{{#if semanticCommitScope}}({{semanticCommitScope}}){{/if}}: {{/if}}some commit message", "commitMessageExtra": "{{currentValue}} something", @@ -276,51 +322,6 @@ Object { } `; -exports[`config/migration migrateConfig(config, parentConfig) it migrates packageRules 1`] = ` -Object { - "packageRules": Array [ - Object { - "excludePackageNames": Array [ - "baz", - ], - "excludePackagePatterns": Array [ - "^baz", - ], - "matchBaseBranches": Array [ - "master", - ], - "matchDatasources": Array [ - "orb", - ], - "matchDepTypes": Array [ - "peerDependencies", - ], - "matchLanguages": Array [ - "python", - ], - "matchManagers": Array [ - "dockerfile", - ], - "matchPackageNames": Array [ - "foo", - ], - "matchPackagePatterns": Array [ - "^bar", - ], - "matchPaths": Array [ - "package.json", - ], - "matchSourceUrlPrefixes": Array [ - "https://github.com/vuejs/vue", - ], - "matchUpdateTypes": Array [ - "major", - ], - }, - ], -} -`; - exports[`config/migration migrateConfig(config, parentConfig) migrates packages 1`] = ` Object { "packageRules": Array [ diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index 4e6787d04c9a301527ffe0c1873cab1e7d5a6992..7c1d16e4df9d51a8efdbab0dc0fc8ad32f615d2e 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -46,6 +46,8 @@ describe('config/migration', () => { gomodTidy: true, upgradeInRange: true, automergeType: 'branch-push', + branchName: + '{{{branchPrefix}}}{{{managerBranchPrefix}}}{{{branchTopic}}}', baseBranch: 'next', managerBranchPrefix: 'foo', branchPrefix: 'renovate/{{parentDir}}-', diff --git a/lib/config/migration.ts b/lib/config/migration.ts index 16e15c7cecd75a4d315eef0ba965406fd5c89c54..5b586159a37becf6f84ab45bd9ef0ce7d1e1c91e 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -191,6 +191,15 @@ export function migrateConfig( } else if (val === false) { migratedConfig.trustLevel = 'low'; } + } else if ( + key === 'branchName' && + is.string(val) && + val?.includes('{{managerBranchPrefix}}') + ) { + migratedConfig.branchName = val.replace( + '{{managerBranchPrefix}}', + '{{additionalBranchPrefix}}' + ); } else if (key === 'managerBranchPrefix') { delete migratedConfig.managerBranchPrefix; migratedConfig.additionalBranchPrefix = val; @@ -491,7 +500,9 @@ export function migrateConfig( .replace(/currentVersion/g, 'currentValue') .replace(/newVersion/g, 'newValue') .replace(/newValueMajor/g, 'newMajor') - .replace(/newValueMinor/g, 'newMinor'); + .replace(/newValueMinor/g, 'newMinor') + .replace(/newVersionMajor/g, 'newMajor') + .replace(/newVersionMinor/g, 'newMinor'); } else if (key === 'raiseDeprecationWarnings') { delete migratedConfig.raiseDeprecationWarnings; if (val === false) { diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts index 50b5ed6f002fce60a608f8f03f96d6b93c7f2b38..612b9f279cccc493f1bd46bd970615f9f382759b 100644 --- a/lib/util/template/index.ts +++ b/lib/util/template/index.ts @@ -85,6 +85,8 @@ export const allowedFields = { releases: 'An array of releases for an upgrade', releaseNotes: 'A ChangeLogNotes object for the release', repository: 'The current repository', + semanticPrefix: 'The fully generated semantic prefix for commit messages', + sourceUrl: 'The source URL for the package', toVersion: 'The new version in the upgrade, e.g. "3.1.0"', updateType: 'One of digest, pin, rollback, patch, minor, major', upgrades: 'An array of upgrade objects in the branch', @@ -144,14 +146,16 @@ export function compile( ): string { const filteredInput = filterFields ? getFilteredObject(input) : input; logger.trace({ template, filteredInput }, 'Compiling template'); - const matches = template.matchAll(templateRegex); - for (const match of matches) { - const varName = match[3]; - if (!allowedFieldsList.includes(varName)) { - logger.info( - { varName, template }, - 'Disallowed variable name in template' - ); + if (filterFields) { + const matches = template.matchAll(templateRegex); + for (const match of matches) { + const varName = match[3]; + if (!allowedFieldsList.includes(varName)) { + logger.info( + { varName, template }, + 'Disallowed variable name in template' + ); + } } } return handlebars.compile(template)(filteredInput);