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

#1367: added fix to java version compare #1375

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
hohwille marked this conversation as resolved.
Show resolved Hide resolved
doTestVersionCompare 21_35 '<' 21_36
doTestVersionCompare 21_35 '<' 21_36.2

exit "${exitcode}"
Loading