diff --git a/lib/workers/repository/updates/flatten.ts b/lib/workers/repository/updates/flatten.ts index f5ec68a68483f0553c69f97b8f67dca6397795de..73cfce1bd14dddc70367015f9d2cc25577e45497 100644 --- a/lib/workers/repository/updates/flatten.ts +++ b/lib/workers/repository/updates/flatten.ts @@ -8,11 +8,38 @@ import { LANGUAGE_DOCKER } from '../../../constants/languages'; import { getDefaultConfig } from '../../../datasource'; import { get } from '../../../manager'; import { applyPackageRules } from '../../../util/package-rules'; +import { BranchUpgradeConfig } from '../../common'; import { generateBranchName } from './branch-name'; const upper = (str: string): string => str.charAt(0).toUpperCase() + str.substr(1); +export function applyUpdateConfig(input: BranchUpgradeConfig): any { + const updateConfig = { ...input }; + delete updateConfig.packageRules; + // TODO: Remove next line once #8075 is complete + updateConfig.depNameShort ||= updateConfig.depName; + updateConfig.depNameSanitized = updateConfig.depName + ? updateConfig.depName + .replace('@types/', '') + .replace('@', '') + .replace(/\//g, '-') + .replace(/\s+/g, '-') + .replace(/-+/, '-') + .toLowerCase() + : undefined; + if ( + updateConfig.language === LANGUAGE_DOCKER && + /(^|\/)node$/.exec(updateConfig.depName) && + updateConfig.depName !== 'calico/node' + ) { + updateConfig.additionalBranchPrefix = ''; + updateConfig.depNameSanitized = 'node'; + } + generateBranchName(updateConfig); + return updateConfig; +} + export async function flattenUpdates( config: RenovateConfig, packageFiles: Record<string, any[]> @@ -75,30 +102,7 @@ export async function flattenUpdates( } // Apply again in case any were added by the updateType config updateConfig = applyPackageRules(updateConfig); - delete updateConfig.packageRules; - // TODO: Remove next line once #8075 is complete - updateConfig.depNameShort ||= updateConfig.depName; - updateConfig.depNameSanitized = updateConfig.depName - ? updateConfig.depName - .replace('@types/', '') - .replace('@', '') - .replace(/\//g, '-') - .replace(/\s+/g, '-') - .replace(/-+/, '-') - .toLowerCase() - : undefined; - if ( - updateConfig.language === LANGUAGE_DOCKER && - updateConfig.depName.match(/(^|\/)node$/) && - updateConfig.depName !== 'calico/node' - ) { - updateConfig.additionalBranchPrefix = ''; - updateConfig.depNameSanitized = 'node'; - } - generateBranchName(updateConfig); - update.branchName = updateConfig.branchName; // for writing to cache - delete updateConfig.repoIsOnboarded; - delete updateConfig.renovateJsonPresent; + updateConfig = applyUpdateConfig(updateConfig); updateConfig.baseDeps = packageFile.deps; updates.push(updateConfig); }