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(manager/bundler): Allow upgrading bundler itself #27460

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 23 additions & 1 deletion lib/modules/manager/bundler/artifacts.spec.ts
Original file line number Diff line number Diff line change
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' }]);
});

benlangfeld marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
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
Loading