Skip to content

Commit

Permalink
#1367: added fix to java version compare (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattesMrzik authored Jan 5, 2024
1 parent 3c6c604 commit 9c13885
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,20 @@ function doVersionCompare() {
then
local p1="${v1/[^0-9]*/}"
local p2="${v2/[^0-9]*/}"

# java versions may contain "_" indicating probably a build number
# let the major version be x and the build number y then the desired behaviour is x_y < x.0.1
if [ "${p1}" = "${p2}" ]
then
if [[ "${s1}" =~ "_" ]] && ! [[ "${s2}" =~ "_" ]]
then
return 2
fi
if [[ "${s2}" =~ "_" ]] && ! [[ "${s1}" =~ "_" ]]
then
return 1
fi
fi
local n1="${p1}"
local n2="${p2}"
if [ -z "${n1}" ]
Expand Down
5 changes: 5 additions & 0 deletions scripts/src/test/bash/test-version-compare
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,10 @@ doTestVersionCompare 3.0.0-beta17 '>' 3.0.0-beta11-SNAPSHOT
doTestVersionCompare 3.0.0.11 '>' 3.0.0-beta11-SNAPSHOT
doTestVersionCompare 2020.04.001 '>' 3.3.1
doTestVersionCompare "11*" '>' "11u0"
doTestVersionCompare 21.0.1_12 '>' 21_35
doTestVersionCompare 21_35 '<' 21.0.1_12
doTestVersionCompare 21_35 '<' 21
doTestVersionCompare 21_35 '<' 21_36
doTestVersionCompare 21_35 '<' 21_36.2

exit "${exitcode}"

0 comments on commit 9c13885

Please sign in to comment.