diff --git a/lib/workers/repository/update/branch/get-updated.spec.ts b/lib/workers/repository/update/branch/get-updated.spec.ts index ab63ca482a5246..123485920d9c87 100644 --- a/lib/workers/repository/update/branch/get-updated.spec.ts +++ b/lib/workers/repository/update/branch/get-updated.spec.ts @@ -8,6 +8,7 @@ import * as _helmv3 from '../../../../modules/manager/helmv3'; import * as _npm from '../../../../modules/manager/npm'; import * as _pep621 from '../../../../modules/manager/pep621'; import * as _poetry from '../../../../modules/manager/poetry'; +import type { PackageFile } from '../../../../modules/manager/types'; import type { BranchConfig, BranchUpgradeConfig } from '../../../types'; import * as _autoReplace from './auto-replace'; import { getUpdatedPackageFiles } from './get-updated'; @@ -204,6 +205,42 @@ describe('workers/repository/update/branch/get-updated', () => { }); }); + it('for lockFileMaintenance passes proper lockFiles', async () => { + config.upgrades.push({ + manager: 'composer', + updateType: 'lockFileMaintenance', + packageFile: 'composer.json', + branchName: 'some-branch', + } satisfies BranchUpgradeConfig); + config.lockFiles = ['different.lock']; + config.packageFiles = { + composer: [ + { + packageFile: 'composer.json', + lockFiles: ['composer.lock'], + deps: [], + }, + ] satisfies PackageFile[], + }; + composer.updateArtifacts.mockResolvedValueOnce([ + { + file: { + type: 'addition', + path: 'composer.json', + contents: 'some contents', + }, + }, + ]); + await getUpdatedPackageFiles(config); + expect(composer.updateArtifacts).toHaveBeenCalledWith( + expect.objectContaining({ + config: expect.objectContaining({ + lockFiles: ['composer.lock'], + }), + }), + ); + }); + it('handles isRemediation success', async () => { config.upgrades.push({ manager: 'npm', diff --git a/lib/workers/repository/update/branch/get-updated.ts b/lib/workers/repository/update/branch/get-updated.ts index 984edda37579ed..70882094557b1e 100644 --- a/lib/workers/repository/update/branch/get-updated.ts +++ b/lib/workers/repository/update/branch/get-updated.ts @@ -6,6 +6,7 @@ import { get } from '../../../../modules/manager'; import type { ArtifactError, PackageDependency, + PackageFile, UpdateArtifact, UpdateArtifactsResult, } from '../../../../modules/manager/types'; @@ -342,7 +343,11 @@ export async function getUpdatedPackageFiles( packageFileName, updatedDeps: [], newPackageFileContent: contents!, - config, + config: patchConfigForArtifactsUpdate( + config, + manager, + packageFileName, + ), }); processUpdateArtifactResults( results, @@ -361,6 +366,26 @@ export async function getUpdatedPackageFiles( }; } +// workaround, see #27319 +function patchConfigForArtifactsUpdate( + config: BranchConfig, + manager: string, + packageFileName: string, +): BranchConfig { + const updatedConfig = { ...config }; + if (is.nonEmptyArray(updatedConfig.packageFiles?.[manager])) { + const managerPackageFiles: PackageFile[] = + updatedConfig.packageFiles?.[manager]; + const packageFile = managerPackageFiles.find( + (p) => p.packageFile === packageFileName, + ); + if (packageFile) { + updatedConfig.lockFiles ??= packageFile.lockFiles; + } + } + return updatedConfig; +} + async function managerUpdateArtifacts( manager: string, updateArtifact: UpdateArtifact,