Skip to content

Commit

Permalink
fix(manager/bundler): Allow upgrading bundler itself (#27460)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Feb 21, 2024
1 parent ece0bf6 commit 2c2608f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
24 changes: 23 additions & 1 deletion lib/modules/manager/bundler/artifacts.spec.ts
Expand Up @@ -947,7 +947,7 @@ describe('modules/manager/bundler/artifacts', () => {
]);
});

it('updates the Gemfile.lock when ruby upgraded', async () => {
it('updates the Gemfile.lock when upgrading ruby', async () => {
// See https://github.com/renovatebot/renovate/issues/15114
fs.readLocalFile.mockResolvedValue('Current Gemfile.lock');
const execSnapshots = mockExecSequence([{ stdout: '', stderr: '' }]);
Expand All @@ -967,6 +967,28 @@ describe('modules/manager/bundler/artifacts', () => {
expect(res).toMatchObject([{ file: { path: 'Gemfile.lock' } }]);
expect(execSnapshots).toMatchObject([{ cmd: 'bundler lock' }]);
});

it('updates the Gemfile.lock when upgrading bundler', async () => {
fs.readLocalFile.mockResolvedValue('Current Gemfile.lock');
const execSnapshots = mockExecSequence([{ stdout: '', stderr: '' }]);
git.getRepoStatus.mockResolvedValueOnce(
partial<StatusResult>({
modified: ['Gemfile.lock'],
}),
);

const res = await updateArtifacts({
packageFileName: 'Gemfile',
updatedDeps: [{ depName: 'bundler', updateType: 'patch' }],
newPackageFileContent: '{}',
config,
});

expect(res).toMatchObject([{ file: { path: 'Gemfile.lock' } }]);
expect(execSnapshots).toMatchObject([
{ cmd: 'bundler lock --update --bundler' },
]);
});
});
});
});
9 changes: 8 additions & 1 deletion lib/modules/manager/bundler/artifacts.ts
Expand Up @@ -96,6 +96,13 @@ export async function updateArtifacts(
if (config.isLockFileMaintenance) {
commands.push('bundler lock --update');
} else {
const bundlerUpgraded = updatedDeps
.map((dep) => dep.depName)
.includes('bundler');
if (bundlerUpgraded) {
commands.push('bundler lock --update --bundler');
}

const updateTypes = {
patch: '--patch --strict ',
minor: '--minor --strict ',
Expand All @@ -106,7 +113,7 @@ export async function updateArtifacts(
.filter((dep) => (dep.updateType ?? 'major') === updateType)
.map((dep) => dep.depName)
.filter(is.string)
.filter((dep) => dep !== 'ruby');
.filter((dep) => dep !== 'ruby' && dep !== 'bundler');
let additionalArgs = '';
if (config.postUpdateOptions?.includes('bundlerConservative')) {
additionalArgs = '--conservative ';
Expand Down

0 comments on commit 2c2608f

Please sign in to comment.