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(cpanfile): support version ranges which are not v-prefixed #22259

Merged
merged 2 commits into from May 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions lib/modules/manager/cpanfile/extract.spec.ts
Expand Up @@ -44,6 +44,13 @@ describe('modules/manager/cpanfile/extract', () => {
requires 'URI', '1.59';
requires 'HTTP::Tiny', 0.034;
requires "Capture::Tiny" => "0";

requires 'A', '== 1.1';
requires 'AA', '== v1.1';
requires 'B', '>= 1.2';
requires 'BB', '>= v1.2';
requires 'C', '> 1.3';
requires 'CC', '> v1.3';
`,
'cpanfile'
)
Expand All @@ -69,6 +76,36 @@ describe('modules/manager/cpanfile/extract', () => {
depName: 'Capture::Tiny',
currentValue: '0',
},
{
datasource: 'cpan',
depName: 'A',
currentValue: '1.1',
},
{
datasource: 'cpan',
depName: 'AA',
currentValue: '1.1',
},
{
datasource: 'cpan',
depName: 'B',
currentValue: '1.2',
},
{
datasource: 'cpan',
depName: 'BB',
currentValue: '1.2',
},
{
datasource: 'cpan',
depName: 'C',
currentValue: '1.3',
},
{
datasource: 'cpan',
depName: 'CC',
currentValue: '1.3',
},
],
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/cpanfile/parser.ts
Expand Up @@ -69,7 +69,7 @@ const moduleMatch = q
q.alt<Ctx>(q.op(','), q.op('=>')).alt(
q.num<Ctx>((ctx, { value: currentValue }) => ({ ...ctx, currentValue })),
q.str<Ctx>((ctx, { value }) => {
const currentValue = value.replace(/^(?:\s*(?:==|>=|>))?\s*v/, '');
const currentValue = value.replace(/^(?:\s*(?:==|>=|>))?\s*v?/, '');
return { ...ctx, currentValue };
})
)
Expand Down