Skip to content
Snippets Groups Projects
Unverified Commit 3f315fb8 authored by Norbert Szulc's avatar Norbert Szulc Committed by GitHub
Browse files

fix(workers/repository): Pass proper lockFiles in lockFileMaintenance (#27319)

parent 752d2520
No related branches found
No related tags found
No related merge requests found
......@@ -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',
......
......@@ -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: 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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment