Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workers/repository): Pass correct lock files when updating a dependency in multiple input files #27898

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions lib/workers/repository/update/branch/get-updated.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,81 @@ describe('workers/repository/update/branch/get-updated', () => {
});
});

it('for updatedArtifacts passes proper lockFiles', async () => {
config.upgrades.push({
packageFile: 'composer.json',
manager: 'composer',
branchName: '',
});
config.lockFiles = ['different.lock'];
config.packageFiles = {
composer: [
{
packageFile: 'composer.json',
lockFiles: ['composer.lock'],
deps: [],
},
] satisfies PackageFile[],
};
autoReplace.doAutoReplace.mockResolvedValueOnce('some new content');
composer.updateArtifacts.mockResolvedValueOnce([
{
file: {
type: 'addition',
path: 'composer.lock',
contents: 'some contents',
},
},
]);
await getUpdatedPackageFiles(config);
expect(composer.updateArtifacts).toHaveBeenCalledWith(
expect.objectContaining({
config: expect.objectContaining({
lockFiles: ['composer.lock'],
}),
}),
);
});

it('for nonUpdatedArtifacts passes proper lockFiles', async () => {
config.upgrades.push({
packageFile: 'composer.json',
manager: 'composer',
branchName: '',
isLockfileUpdate: true,
});
composer.updateLockedDependency.mockReturnValueOnce({
status: 'unsupported',
});
config.lockFiles = ['different.lock'];
config.packageFiles = {
composer: [
{
packageFile: 'composer.json',
lockFiles: ['composer.lock'],
deps: [],
},
] satisfies PackageFile[],
};
composer.updateArtifacts.mockResolvedValueOnce([
{
file: {
type: 'addition',
path: 'composer.lock',
contents: 'some contents',
},
},
]);
await getUpdatedPackageFiles(config);
expect(composer.updateArtifacts).toHaveBeenCalledWith(
expect.objectContaining({
config: expect.objectContaining({
lockFiles: ['composer.lock'],
}),
}),
);
});

it('for lockFileMaintenance passes proper lockFiles', async () => {
config.upgrades.push({
manager: 'composer',
Expand Down
12 changes: 10 additions & 2 deletions lib/workers/repository/update/branch/get-updated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ export async function getUpdatedPackageFiles(
updatedDeps,
// TODO #22198
newPackageFileContent: packageFile.contents!.toString(),
config,
config: patchConfigForArtifactsUpdate(
config,
manager,
packageFile.path,
),
});
processUpdateArtifactResults(results, updatedArtifacts, artifactErrors);
}
Expand All @@ -329,7 +333,11 @@ export async function getUpdatedPackageFiles(
updatedDeps,
// TODO #22198
newPackageFileContent: packageFile.contents!.toString(),
config,
config: patchConfigForArtifactsUpdate(
config,
manager,
packageFile.path,
),
});
processUpdateArtifactResults(results, updatedArtifacts, artifactErrors);
if (is.nonEmptyArray(results)) {
Expand Down
Loading