This commit is contained in:
ldt-fweichert 2025-01-22 23:08:29 +01:00 committed by GitHub
commit 329d04c839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 3 deletions

View file

@ -356,8 +356,12 @@ describe('modules/manager/gradle/parser', () => {
it.each`
input | output
${'"foo:bar:1.2.3"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }}
${'"foo:bar:1.2+"'} | ${{ depName: 'foo:bar', currentValue: '1.2+' }}
${'"foo:bar:1.2.3@zip"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', dataType: 'zip' }}
${'"foo:bar1:1"'} | ${{ depName: 'foo:bar1', currentValue: '1', managerData: { fileReplacePosition: 10 } }}
${'"foo:bar:[1.2.3, )"'} | ${{ depName: 'foo:bar', currentValue: '[1.2.3, )', managerData: { fileReplacePosition: 9 } }}
${'"foo:bar:[1.2.3, 1.2.4)"'} | ${{ depName: 'foo:bar', currentValue: '[1.2.3, 1.2.4)', managerData: { fileReplacePosition: 9 } }}
${'"foo:bar:[,1.2.4)"'} | ${{ depName: 'foo:bar', currentValue: '[,1.2.4)', managerData: { fileReplacePosition: 9 } }}
${'"foo:bar:x86@x86"'} | ${{ depName: 'foo:bar', currentValue: 'x86', managerData: { fileReplacePosition: 9 } }}
${'foo.bar = "foo:bar:1.2.3"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }}
`('$input', ({ input, output }) => {

View file

@ -53,6 +53,9 @@ describe('modules/manager/gradle/utils', () => {
${'foo:bar:1.2.3@zip'} | ${true}
${'foo:bar:x86@x86'} | ${true}
${'foo.bar:baz:1.2.+'} | ${true}
${'foo.bar:baz:[1.6.0, ]'} | ${true}
${'foo.bar:baz:[, 1.6.0)'} | ${true}
${'foo.bar:baz:]1.6.0,]'} | ${true}
${'foo:bar:baz:qux'} | ${false}
${'foo:bar:baz:qux:quux'} | ${false}
${"foo:bar:1.2.3'"} | ${false}
@ -74,6 +77,7 @@ describe('modules/manager/gradle/utils', () => {
${'foo.foo:bar.bar:1.2.3'} | ${{ depName: 'foo.foo:bar.bar', currentValue: '1.2.3' }}
${'foo.bar:baz:1.2.3'} | ${{ depName: 'foo.bar:baz', currentValue: '1.2.3' }}
${'foo:bar:1.2.+'} | ${{ depName: 'foo:bar', currentValue: '1.2.+' }}
${'foo.bar:baz:[1.6.0, ]'} | ${{ depName: 'foo.bar:baz', currentValue: '[1.6.0, ]' }}
${'foo:bar:1.2.3@zip'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', dataType: 'zip' }}
${'foo:bar:baz:qux'} | ${null}
${'foo:bar:baz:qux:quux'} | ${null}

View file

@ -11,7 +11,7 @@ const artifactRegex = regEx(
'^[a-zA-Z][-_a-zA-Z0-9]*(?:\\.[a-zA-Z0-9][-_a-zA-Z0-9]*?)*$',
);
const versionLikeRegex = regEx('^(?<version>[-_.\\[\\](),a-zA-Z0-9+]+)');
const versionLikeRegex = regEx('^(?<version>[-_.\\[\\](),a-zA-Z0-9+ ]+)');
// Extracts version-like and range-like strings from the beginning of input
export function versionLikeSubstring(
@ -22,7 +22,7 @@ export function versionLikeSubstring(
}
const match = versionLikeRegex.exec(input);
const version = match?.groups?.version;
const version = match?.groups?.version?.trim();
if (!version || !regEx(/\d/).test(version)) {
return null;
}

View file

@ -293,6 +293,17 @@ describe('modules/versioning/gradle/index', () => {
${'[1.0,1.2],[1.3,1.5['} | ${'pin'} | ${'1.0'} | ${'1.2.4'} | ${'1.2.4'}
${'[1.2.3,)'} | ${'pin'} | ${'1.2.3'} | ${'1.2.4'} | ${'1.2.4'}
${'[1.2.3,['} | ${'pin'} | ${'1.2.3'} | ${'1.2.4'} | ${'1.2.4'}
${'[1.2.3]'} | ${'bump'} | ${'1.2.3'} | ${'1.2.4'} | ${'[1.2.4]'}
${'[1.0.0,1.2.3]'} | ${'bump'} | ${'1.0.0'} | ${'1.2.4'} | ${'[1.0.0,1.2.4]'}
${'[1.0.0,1.2.23]'} | ${'bump'} | ${'1.0.0'} | ${'1.2.23'} | ${'[1.0.0,1.2.23]'}
${'(,1.0]'} | ${'bump'} | ${'0.0.1'} | ${'2.0'} | ${'(,2.0]'}
${'],1.0]'} | ${'bump'} | ${'0.0.1'} | ${'2.0'} | ${'],2.0]'}
${'(,1.0)'} | ${'bump'} | ${'0.1'} | ${'2.0'} | ${'(,3.0)'}
${'],1.0['} | ${'bump'} | ${'2.0'} | ${'],2.0['} | ${'],1.0['}
${'[1.0,1.2],[1.3,1.5)'} | ${'bump'} | ${'1.0'} | ${'1.2.4'} | ${'[1.0,1.2],[1.3,1.5)'}
${'[1.0,1.2],[1.3,1.5['} | ${'bump'} | ${'1.0'} | ${'1.2.4'} | ${'[1.0,1.2],[1.3,1.5['}
${'[1.2.3,)'} | ${'bump'} | ${'1.2.3'} | ${'1.2.4'} | ${'[1.2.4,)'}
${'[1.2.3,['} | ${'bump'} | ${'1.2.3'} | ${'1.2.4'} | ${'[1.2.4,['}
`(
'getNewValue($currentValue, $rangeStrategy, $currentVersion, $newVersion, $expected) === $expected',
({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => {

View file

@ -18,7 +18,7 @@ export const urls = [
'https://docs.gradle.org/current/userguide/single_versions.html#version_ordering',
];
export const supportsRanges = true;
export const supportedRangeStrategies: RangeStrategy[] = ['pin'];
export const supportedRangeStrategies: RangeStrategy[] = ['pin', 'bump'];
const equals = (a: string, b: string): boolean => compare(a, b) === 0;