diff --git a/lib/modules/manager/bundler/artifacts.spec.ts b/lib/modules/manager/bundler/artifacts.spec.ts index d4bbf4d8b8e8661ad265250a400456aece039828..d8fdc1c09e04339f464cdc48713dd2e01b126ff9 100644 --- a/lib/modules/manager/bundler/artifacts.spec.ts +++ b/lib/modules/manager/bundler/artifacts.spec.ts @@ -103,6 +103,29 @@ describe('modules/manager/bundler/artifacts', () => { ]); }); + it('executes commands from lockFile path', async () => { + fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); + fs.writeLocalFile.mockResolvedValueOnce(); + const execSnapshots = mockExecAll(); + git.getRepoStatus.mockResolvedValueOnce( + partial<StatusResult>({ + modified: [], + }) + ); + fs.readLocalFile.mockResolvedValueOnce('Updated Gemfile.lock'); + expect( + await updateArtifacts({ + packageFileName: 'teamA/Gemfile', + updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }], + newPackageFileContent: 'Updated Gemfile content', + config, + }) + ).toBeNull(); + expect(execSnapshots).toMatchObject([ + { options: { cwd: '/tmp/github/some/repo' } }, + ]); + }); + it('works for default binarySource', async () => { fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.readLocalFile.mockResolvedValueOnce(null); diff --git a/lib/modules/manager/bundler/artifacts.ts b/lib/modules/manager/bundler/artifacts.ts index 7e363484cea25ef30b0f788feb395a239ff07447..a1a14341248fd907004c9685c8b1bbd2c408f757 100644 --- a/lib/modules/manager/bundler/artifacts.ts +++ b/lib/modules/manager/bundler/artifacts.ts @@ -174,7 +174,7 @@ export async function updateArtifacts( } const execOptions: ExecOptions = { - cwdFile: packageFileName, + cwdFile: lockFileName, extraEnv: { ...bundlerHostRulesVariables, GEM_HOME: await ensureCacheDir('bundler'), diff --git a/lib/modules/manager/bundler/common.ts b/lib/modules/manager/bundler/common.ts index 8e35c77ea57b0d1ed7c73ffa1d6da549085cd28f..43e55f5f31df90dc3765782de289e58822023c61 100644 --- a/lib/modules/manager/bundler/common.ts +++ b/lib/modules/manager/bundler/common.ts @@ -76,8 +76,9 @@ export function getBundlerConstraint( export async function getLockFilePath( packageFilePath: string ): Promise<string> { - logger.debug(`Looking for lockfile for ${packageFilePath}`); - return (await localPathExists(`${packageFilePath}.lock`)) + const lockFilePath = (await localPathExists(`${packageFilePath}.lock`)) ? `${packageFilePath}.lock` : `Gemfile.lock`; + logger.debug(`Lockfile for ${packageFilePath} found in ${lockFilePath}`); + return lockFilePath; }