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: include newVersion in composer update command #24057

Merged
merged 5 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 32 additions & 4 deletions lib/modules/manager/composer/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ describe('modules/manager/composer/artifacts', () => {
expect(
await composer.updateArtifacts({
packageFileName: 'composer.json',
updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }],
updatedDeps: [
{ depName: 'foo', newVersion: '1' },
{ depName: 'bar', newVersion: '2' },
erikgaal marked this conversation as resolved.
Show resolved Hide resolved
],
newPackageFileContent: '{}',
config,
})
).toBeNull();
expect(execSnapshots).toMatchObject([
{
cmd: 'composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction',
cmd: 'composer update foo:1 bar:2 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction',
erikgaal marked this conversation as resolved.
Show resolved Hide resolved
options: {
cwd: '/tmp/github/some/repo',
env: {
Expand Down Expand Up @@ -1146,14 +1149,17 @@ describe('modules/manager/composer/artifacts', () => {
expect(
await composer.updateArtifacts({
packageFileName: 'composer.json',
updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }],
updatedDeps: [
{ depName: 'foo', newVersion: '1' },
{ depName: 'bar', newVersion: '2' },
],
newPackageFileContent: '{}',
config,
})
).toBeNull();
expect(execSnapshots).toMatchObject([
{
cmd: 'composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader',
cmd: 'composer update foo:1 bar:2 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader',
options: { cwd: '/tmp/github/some/repo' },
},
]);
Expand Down Expand Up @@ -1183,4 +1189,26 @@ describe('modules/manager/composer/artifacts', () => {
},
]);
});

it('includes new dependency version in update command', async () => {
fs.readLocalFile.mockResolvedValueOnce('{}');
const execSnapshots = mockExecAll();
fs.readLocalFile.mockResolvedValueOnce('{}');
git.getRepoStatus.mockResolvedValueOnce(repoStatus);

expect(
await composer.updateArtifacts({
packageFileName: 'composer.json',
updatedDeps: [{ depName: 'foo', newVersion: '1.1.0' }],
rarkins marked this conversation as resolved.
Show resolved Hide resolved
newPackageFileContent: '{}',
config,
})
).toBeNull();
expect(execSnapshots).toMatchObject([
{
cmd: 'composer update foo:1.1.0 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins',
options: { cwd: '/tmp/github/some/repo' },
},
]);
});
});
4 changes: 3 additions & 1 deletion lib/modules/manager/composer/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ export async function updateArtifacts({
(
'update ' +
updatedDeps
.map((dep) => dep.depName)
.map((dep) =>
dep.newVersion ? `${dep.depName}:${dep.newVersion}` : dep.depName
)
.filter(is.string)
.map((dep) => quote(dep))
.join(' ')
Expand Down