From 2d6b82c1ca967123b26c43b418538b7928e1e414 Mon Sep 17 00:00:00 2001 From: Ben Langfeld Date: Tue, 20 Feb 2024 14:49:59 +0000 Subject: [PATCH] Update Gemfile.lock when only Ruby upgraded Fixes #15114 which was broken again by 77e106841cd4490353ca23205227ee57fdefef28. --- lib/modules/manager/bundler/artifacts.spec.ts | 21 +++++++++++++++++++ lib/modules/manager/bundler/artifacts.ts | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/lib/modules/manager/bundler/artifacts.spec.ts b/lib/modules/manager/bundler/artifacts.spec.ts index 66cb6af9da5584..3167439bc870d5 100644 --- a/lib/modules/manager/bundler/artifacts.spec.ts +++ b/lib/modules/manager/bundler/artifacts.spec.ts @@ -946,6 +946,27 @@ describe('modules/manager/bundler/artifacts', () => { { cmd: 'bundler lock --minor --conservative --update foo' }, ]); }); + + it('updates the Gemfile.lock when ruby upgraded', async () => { + // See https://github.com/renovatebot/renovate/issues/15114 + fs.readLocalFile.mockResolvedValue('Current Gemfile.lock'); + const execSnapshots = mockExecSequence([{ stdout: '', stderr: '' }]); + git.getRepoStatus.mockResolvedValueOnce( + partial({ + modified: ['Gemfile.lock'], + }), + ); + + const res = await updateArtifacts({ + packageFileName: 'Gemfile', + updatedDeps: [{ depName: 'ruby', updateType: 'patch' }], + newPackageFileContent: '{}', + config, + }); + + expect(res).toMatchObject([{ file: { path: 'Gemfile.lock' } }]); + expect(execSnapshots).toMatchObject([{ cmd: 'bundler lock' }]); + }); }); }); }); diff --git a/lib/modules/manager/bundler/artifacts.ts b/lib/modules/manager/bundler/artifacts.ts index 60e17f6f4fea8e..87208070959938 100644 --- a/lib/modules/manager/bundler/artifacts.ts +++ b/lib/modules/manager/bundler/artifacts.ts @@ -121,6 +121,13 @@ export async function updateArtifacts( commands.push(cmd); } } + + const rubyUpgraded = updatedDeps + .map((dep) => dep.depName) + .includes('ruby'); + if (rubyUpgraded) { + commands.push('bundler lock'); + } } const bundlerHostRules = findAllAuthenticatable({