Skip to content

Commit

Permalink
Fix hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel-Rodriguez committed Nov 23, 2020
1 parent ceca77d commit 8d53b4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions semver2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ semver_compare() {
a_patch=$(printf %s "$version_a" | cut -d'.' -f 3 | cut -d'-' -f 1)
a_pre=""
if [ "$(includesString "$version_a" -)" = 1 ]; then
a_pre=$(printf %s "$version_a" | cut -d'-' -f 2)
a_pre=$(printf %s"${version_a#$a_major.$a_minor.$a_patch-}")
fi

b_major=$(printf %s "$version_b" | cut -d'.' -f 1)
b_minor=$(printf %s "$version_b" | cut -d'.' -f 2)
b_patch=$(printf %s "$version_b" | cut -d'.' -f 3 | cut -d'-' -f 1)
b_pre=""
if [ "$(includesString "$version_b" -)" = 1 ]; then
b_pre=$(printf %s "$version_b" | cut -d'-' -f 2)
b_pre=$(printf %s"${version_b#$b_major.$b_minor.$b_patch-}")
fi

unit_types="MAJOR MINOR PATCH"
Expand Down Expand Up @@ -323,4 +323,4 @@ semver_compare() {
done
}

[ -n "$1" ] && printf "%s$(semver_compare "$@")\n"
printf "%s$(semver_compare "$@")\n"
4 changes: 3 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
set -eu

# Include semver_compare tool
source ./semver2.sh
source ./semver2.sh 1.0.0 1.0.0

# semver2.0 happy path tests ordered by precedence
# spec 11.4
# 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
tests=(
1.0.0-0-0
1.0.0-0-1
1.0.0-alpha
1.0.0-alpha.1
1.0.0-alpha.beta
Expand Down

0 comments on commit 8d53b4c

Please sign in to comment.