Skip to content

Commit

Permalink
fix(maven): Support versions containing + sign (#21533)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Apr 16, 2023
1 parent 31a7db6 commit 6d0aeee
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
18 changes: 16 additions & 2 deletions lib/modules/versioning/ivy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,27 @@ function isValid(str: string): boolean {
if (!str) {
return false;
}
return maven.isVersion(str) || !!parseDynamicRevision(str);

if (LATEST_REGEX.test(str)) {
return true;
}

return isVersion(str) || !!parseDynamicRevision(str);
}

function isVersion(str: string): boolean {
if (!str || LATEST_REGEX.test(str)) {
if (!str) {
return false;
}

if (LATEST_REGEX.test(str)) {
return false;
}

if (str.includes('+')) {
return false;
}

return maven.isVersion(str);
}

Expand Down
1 change: 1 addition & 0 deletions lib/modules/versioning/maven/compare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ describe('modules/versioning/maven/compare', () => {
${'1-0.alpha'} | ${'1-0.beta'}
${'1_5ea'} | ${'1_c3b'}
${'1_c3b'} | ${'2'}
${'17.0.5'} | ${'17.0.5+8'}
`('$x < $y', ({ x, y }) => {
expect(compare(x, y)).toBe(-1);
expect(compare(y, x)).toBe(1);
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/versioning/maven/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function isDigit(char: string): boolean {
}

function isLetter(char: string): boolean {
return regEx(/^[a-z_]$/i).test(char);
return regEx(/^[a-z_+]$/i).test(char);
}

function isTransition(prevChar: string, nextChar: string): boolean {
Expand Down Expand Up @@ -281,7 +281,7 @@ function isVersion(version: unknown): version is string {
if (!version || typeof version !== 'string') {
return false;
}
if (!regEx(/^[a-z_0-9.-]+$/i).test(version)) {
if (!regEx(/^[-.a-z_+0-9]+$/i).test(version)) {
return false;
}
if (regEx(/^[.-]/).test(version)) {
Expand Down
1 change: 1 addition & 0 deletions lib/modules/versioning/maven/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('modules/versioning/maven/index', () => {
test.each`
version | expected
${'1.0.0'} | ${true}
${'17.0.5+8'} | ${true}
${'[1.12.6,1.18.6]'} | ${true}
${undefined} | ${false}
`('isValid("$version") === $expected', ({ version, expected }) => {
Expand Down

0 comments on commit 6d0aeee

Please sign in to comment.