Skip to content

Commit

Permalink
feat(bundler): add inline source support (renovatebot#32600)
Browse files Browse the repository at this point in the history
  • Loading branch information
Djiit authored and ssams committed Dec 2, 2024
1 parent 18f1722 commit 81921cd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
44 changes: 36 additions & 8 deletions lib/modules/manager/bundler/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ describe('modules/manager/bundler/extract', () => {

it('parses source variable in Gemfile', async () => {
const sourceVariableGemfile = codeBlock`
source "https://rubygems.org"
ruby '~> 1.5.3'
foo = 'https://gems.foo.com'
bar = 'https://gems.bar.com'
Expand All @@ -159,12 +157,42 @@ describe('modules/manager/bundler/extract', () => {

fs.readLocalFile.mockResolvedValueOnce(sourceVariableGemfile);
const res = await extractPackageFile(sourceVariableGemfile, 'Gemfile');
expect(res?.deps).toHaveLength(2);
expect(res?.registryUrls).toHaveLength(2);
expect(res?.registryUrls?.[1]).toBe('https://gems.foo.com');
expect(res?.deps[1]).toMatchObject({
depName: 'some_internal_gem',
registryUrls: ['https://gems.bar.com'],
expect(res).toMatchObject({
registryUrls: ['https://gems.foo.com'],
deps: [
{
depName: 'some_internal_gem',
registryUrls: ['https://gems.bar.com'],
},
],
});
});

it('parses inline source in Gemfile', async () => {
const sourceInlineGemfile = codeBlock`
baz = 'https://gems.baz.com'
gem "inline_source_gem", source: 'https://gems.foo.com'
gem 'inline_source_gem_with_version', "~> 1", source: 'https://gems.bar.com'
gem 'inline_source_gem_with_variable_source', source: baz
`;
fs.readLocalFile.mockResolvedValueOnce(sourceInlineGemfile);
const res = await extractPackageFile(sourceInlineGemfile, 'Gemfile');
expect(res).toMatchObject({
deps: [
{
depName: 'inline_source_gem',
registryUrls: ['https://gems.foo.com'],
},
{
depName: 'inline_source_gem_with_version',
currentValue: '"~> 1"',
registryUrls: ['https://gems.bar.com'],
},
{
depName: 'inline_source_gem_with_variable_source',
registryUrls: ['https://gems.baz.com'],
},
],
});
});
});
8 changes: 8 additions & 0 deletions lib/modules/manager/bundler/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ export async function extractPackageFile(
const currentValue = gemMatch.groups.currentValue;
dep.currentValue = currentValue;
}
if (gemMatch.groups?.registryUrl) {
const registryUrl = gemMatch.groups.registryUrl;
dep.registryUrls = [registryUrl];
}
if (gemMatch.groups?.sourceName) {
const registryUrl = variables[gemMatch.groups.sourceName];
dep.registryUrls = [registryUrl];
}
dep.datasource = RubygemsDatasource.id;
res.deps.push(dep);
}
Expand Down

0 comments on commit 81921cd

Please sign in to comment.