From 8b731042d7922207b24544908ab6ba3d40bae98c Mon Sep 17 00:00:00 2001 From: Erik Gaal <me@erikgaal.nl> Date: Fri, 25 Aug 2023 14:03:23 +0200 Subject: [PATCH] fix: include newVersion in composer update command (#24057) Co-authored-by: Rhys Arkins <rhys@arkins.net> Co-authored-by: Michael Kriese <michael.kriese@visualon.de> --- .../manager/composer/artifacts.spec.ts | 36 ++++++++++++++++--- lib/modules/manager/composer/artifacts.ts | 4 ++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/lib/modules/manager/composer/artifacts.spec.ts b/lib/modules/manager/composer/artifacts.spec.ts index 779ac1bdf5..7ad1a8bc21 100644 --- a/lib/modules/manager/composer/artifacts.spec.ts +++ b/lib/modules/manager/composer/artifacts.spec.ts @@ -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.0.0' }, + { depName: 'bar', newVersion: '2.0.0' }, + ], 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.0.0 bar:2.0.0 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction', options: { cwd: '/tmp/github/some/repo', env: { @@ -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.0.0' }, + { depName: 'bar', newVersion: '2.0.0' }, + ], 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.0.0 bar:2.0.0 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader', options: { cwd: '/tmp/github/some/repo' }, }, ]); @@ -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' }], + 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' }, + }, + ]); + }); }); diff --git a/lib/modules/manager/composer/artifacts.ts b/lib/modules/manager/composer/artifacts.ts index 104cbfe0c5..74113bff12 100644 --- a/lib/modules/manager/composer/artifacts.ts +++ b/lib/modules/manager/composer/artifacts.ts @@ -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(' ') -- GitLab