Skip to content

Commit

Permalink
Improve PADD version comparison
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <ckoenig@posteo.de>
  • Loading branch information
yubiuser committed Jun 29, 2022
1 parent b70016d commit c74ed15
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion padd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,11 @@ GetVersionInformation() {
if [ "${padd_version_latest}" = "" ]; then
padd_version_heatmap=${yellow_text}
else
if [ "${padd_version}" != "${padd_version_latest}" ]; then
if [ $(VersionConverter "${padd_version}") -lt $(VersionConverter "${padd_version_latest}") ]; then
padd_out_of_date_flag="true"
padd_version_heatmap=${red_text}
else
# local and remote PADD version match or local is newer
padd_version_heatmap=${green_text}
fi
fi
Expand Down Expand Up @@ -1060,6 +1061,12 @@ CheckConnectivity() {
fi
}

# converts a given version string e.g. v3.7.1 to 3007001000 to allow for easier comparison of multi digit version numbers
# credits https://apple.stackexchange.com/a/123408
VersionConverter() {
echo "$@" | tr -d '[:alpha:]' | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
}

########################################## MAIN FUNCTIONS ##########################################

OutputJSON() {
Expand Down

0 comments on commit c74ed15

Please sign in to comment.