Skip to content

Commit

Permalink
#427: keep leading zeros (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Jul 30, 2020
1 parent b98e314 commit 0f31c00
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ function doGetNextVersion() {
local version="${1}"
local suffix="${version##*[0-9]}"
local prefix=""
local last=""
local next=""
local begin="${version:0:(${#version}-${#suffix})}"
if [ -n "${begin}" ]
Expand All @@ -1098,8 +1099,13 @@ function doGetNextVersion() {
fi
done
prefix="${begin:0:(${i})}"
next="${begin:(${i}):(${#begin}-${i})}"
next=$((next+1))
last="${begin:(${i}):(${#begin}-${i})}"
next=$((last+1))
# https://github.com/devonfw/ide/issues/427
if [ "${#last}" -gt "${#next}" ]
then
next="${last:0:(${#last}-${#next})}${next}"
fi
fi
echo "${prefix}${next}${suffix}"
}
Expand Down
22 changes: 22 additions & 0 deletions scripts/src/test/bash/test-get-next-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

cd ../../../../scripts/src/main/resources || exit 1
exitcode=0
source scripts/functions
echo "Testing getNextVersion"
function doTestGetNextVersion() {
result=$(doGetNextVersion "${1}")
status="OK"
if [ "${result}" != "${2}" ]
then
status="NOK - was ${result}"
fi
echo "doGetNextVersion ${1} == ${2} ? ${status}"
}
doTestGetNextVersion 3.0.0-beta8 3.0.0-beta9
doTestGetNextVersion 3.0.0-beta01 3.0.0-beta02
doTestGetNextVersion 3.0.0-beta9 3.0.0-beta10
doTestGetNextVersion 2020.04.01 2020.04.02
doTestGetNextVersion 2020.04.001 2020.04.002

exit "${exitcode}"

0 comments on commit 0f31c00

Please sign in to comment.