-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "bump prerel" with an incrementing numeric portion.
The basic approach is that currently disallowed usages of "bump prerel" can be used to introduce numerical bumping of a trailing numeric portion of a PRERELEASE string. Previously, "bump prerel" required an argument that was simply used as the new PRERELEASE string; with any BUILD part removed. The argument needed to be a correct PRERELEASE string. In particular, it could not contain a trailing dot. Here, a trailing dot denotes a numeric portion that is either created or updated. "Updated" means "incremented by one". The previous functionality (simple replacement) remains. If a trailing dot is present, the "<prerel>" argument is used as a prototype and the new functionality is invoked. Note that any BUILD part is always removed. For example, here a PRERELEASE field with an initial value is created: semver bump prerel rc. 1.0.1 => 1.0.1-rc1 If the prototype matches the existing PRERELEASE part, then the numeric portion is incremented: semver bump prerel rc. 1.0.1-rc1 => 1.0.1-rc2 This is important for scripting: the same prototype argument can be used for initial and subsequent applications, removing the need for different flows or external state. If the existing PRERELEASE does not match the prototype, the prototype is used as in the first example above. Note that it is possible to add (or increment) a numerical portion as a separate identifier within the PRERELEASE field using two dots: semver bump prerel beta.. 2.2.0 => 2.2.0-beta.1 Using a separate identifier is "safer" in that it avoids false version comparisons when, for example, the numeric portion increments from 9 to 10. 6.4.0-beta9 is "greater" than 6.4.0-beta10 given the semantic versioning comparison rules while 6.4.0-beta.9 is "less" than 6.4.0-beta.10 Previously, "bump prerel" required two arguments (new PRERELEASE and existing version). With this new functionality, "bump prerel" with a single argument (existing version) implies adding or incrementing a trailing numerical portion based solely on the existing (or empty) PRERELEASE field: if the numerical portion exists, it is incremented; if not, it is added starting at one. Some examples: semver bump prerel 5.2.1-rc2 => 5.2.1-rc3 semver bump prerel 5.2.1-beta => 5.2.1-beta1 semver bump prerel 5.2.1 => 5.2.1-1 Also: the semver tool version string is now set to 3.2.0 This new functionality is backwards compatible with 3.1.0 The USAGE string and README.md have been updated. Examples demonstrating the new functionality have been added. As well, minor corrections have been made to the README and it is (again) in sync with the USAGE string. During the README and USAGE updates, the "diff" command documentation was completed. New unit tests exercising the bump prerel functionality have been added in "tests/bump_prerel.bats". All pass. Manual inspection indicates that all new/changed code paths are tested. The previous test suite passes (no regression) except for the error cases that have now become valid. These tests have been removed. Version 3.2.0 targeted: in semver code and README.md badge.
- Loading branch information
Showing
4 changed files
with
281 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
# "bats" test script for semver-tool. | ||
# Tests number bumping of pre-release part. | ||
# | ||
# see: https://github.com/bats-core/bats-core | ||
# see: https://hub.docker.com/r/bats/bats | ||
# | ||
# N.B. The script assumes that the bats intepreter is invoked from the | ||
# root directory of the semver-tool source tree. | ||
# | ||
# examples: | ||
# run all .bats scripts in "test": | ||
# cd $SEMVER_HOME ; bats test | ||
# | ||
# run all .bats scripts in "test" using docker: | ||
# docker run --rm -v "$(pwd):/mnt" -w /mnt bats/bats:latest test | ||
|
||
SEMVER="src/semver" | ||
|
||
# sanity tests: should pass in all versions | ||
|
||
@test "basic bump prerel (set)" { | ||
result="$($SEMVER bump prerel rc.1 0.2.1)" | ||
[ "$result" = "0.2.1-rc.1" ] | ||
} | ||
|
||
@test "basic bump prerel (replace and strip pre-release and build metadata)" { | ||
result="$($SEMVER bump prerel rc.1 0.2.1-0.2+b13)" | ||
[ "$result" = "0.2.1-rc.1" ] | ||
} | ||
|
||
@test "basic bump prerel (strip build metadata)" { | ||
result="$($SEMVER bump prerel rc.1 0.2.1+b13)" | ||
[ "$result" = "0.2.1-rc.1" ] | ||
} | ||
|
||
# test bump pre-release using the explicit prefix numbering scheme | ||
|
||
@test "bump prerel (add numeric id)" { | ||
result="$($SEMVER bump prerel . 0.2.1)" | ||
[ "$result" = "0.2.1-1" ] | ||
} | ||
|
||
@test "bump prerel (replace with numeric id)" { | ||
result="$($SEMVER bump prerel . 0.2.1-alpha)" | ||
[ "$result" = "0.2.1-1" ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id)" { | ||
result="$($SEMVER bump prerel . 0.2.1-1)" | ||
[ "$result" = "0.2.1-2" ] | ||
} | ||
|
||
@test "bump prerel (add new pre-release part)" { | ||
result="$($SEMVER bump prerel rc. 0.2.1)" | ||
[ "$result" = "0.2.1-rc1" ] | ||
} | ||
|
||
@test "bump prerel (add new pre-release part with separated numeric id)" { | ||
result="$($SEMVER bump prerel rc.. 0.2.1)" | ||
[ "$result" = "0.2.1-rc.1" ] | ||
} | ||
|
||
@test "bump prerel (add numeric id to existing pre-release, similar prefix)" { | ||
result="$($SEMVER bump prerel rc.v. 0.2.1-rc.2)" | ||
[ "$result" = "0.2.1-rc.v1" ] | ||
} | ||
|
||
@test "bump prerel (add numeric id to existing pre-release, similar trailing id)" { | ||
result="$($SEMVER bump prerel rc.3. 0.2.1-rc.3)" | ||
[ "$result" = "0.2.1-rc.31" ] | ||
} | ||
|
||
@test "bump prerel (add numeric id to existing pre-release, similar trailing id - with dot)" { | ||
result="$($SEMVER bump prerel rc.3.. 0.2.1-rc.3)" | ||
[ "$result" = "0.2.1-rc.3.1" ] | ||
} | ||
|
||
@test "bump prerel (add numeric id to existing pre-release)" { | ||
result="$($SEMVER bump prerel rc. 0.2.1-rc)" | ||
[ "$result" = "0.2.1-rc1" ] | ||
} | ||
|
||
@test "bump prerel (replace with new pre-release part)" { | ||
result="$($SEMVER bump prerel rc. 0.2.1-alpha)" | ||
[ "$result" = "0.2.1-rc1" ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id in pre-release part)" { | ||
result="$($SEMVER bump prerel rc. 0.2.1-rc1)" | ||
[ "$result" = "0.2.1-rc2" ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id in pre-release part with dot)" { | ||
result="$($SEMVER bump prerel rc.. 0.2.1-rc.1)" | ||
[ "$result" = "0.2.1-rc.2" ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id in pre-release part, multiple ids)" { | ||
result="$($SEMVER bump prerel v6.rc. 0.2.1-v6.rc1)" | ||
[ "$result" = "0.2.1-v6.rc2" ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id in pre-release part with dot, multiple ids)" { | ||
result="$($SEMVER bump prerel 4.rc.. 0.2.1-4.rc.1)" | ||
[ "$result" = "0.2.1-4.rc.2" ] | ||
} | ||
|
||
# error checking tests, explicit prefix | ||
|
||
@test "bump prerel (inc numeric id in pre-release part, bad pre-release arg)" { | ||
run $SEMVER bump prerel .rc. 0.2.1-rc.1 | ||
[ "$status" -eq 1 ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id in pre-release part, bad version)" { | ||
run $SEMVER bump prerel rc. 0.2.1-.rc.1 | ||
[ "$status" -eq 1 ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id in pre-release part, 2-dot pre-release arg)" { | ||
run $SEMVER bump prerel .. 0.2.1-rc.1 | ||
[ "$status" -eq 1 ] | ||
} | ||
|
||
@test "bump prerel (add numeric id in pre-release part, 2-dot pre-release arg)" { | ||
run $SEMVER bump prerel .. 0.2.1 | ||
[ "$status" -eq 1 ] | ||
} | ||
|
||
|
||
# test bump pre-release using the implicit numbering scheme | ||
|
||
@test "bump prerel (inc numeric id in pre-release part, no-arg)" { | ||
result="$($SEMVER bump prerel 0.2.1-rc.1)" | ||
[ "$result" = "0.2.1-rc.2" ] | ||
} | ||
|
||
@test "bump prerel (add numeric id, no-arg)" { | ||
result="$($SEMVER bump prerel 0.2.1)" | ||
[ "$result" = "0.2.1-1" ] | ||
} | ||
|
||
@test "bump prerel (append numeric id to pre-release part, no-arg)" { | ||
result="$($SEMVER bump prerel 0.2.1-alpha)" | ||
[ "$result" = "0.2.1-alpha1" ] | ||
} | ||
|
||
@test "bump prerel (inc numeric id, no-arg)" { | ||
result="$($SEMVER bump prerel 0.2.1-1)" | ||
[ "$result" = "0.2.1-2" ] | ||
} | ||
|
||
# error checking tests, implicit prefix | ||
|
||
@test "bump prerel (add numeric id in pre-release part, bad version)" { | ||
run $SEMVER bump prerel 0.2.1-rc. | ||
[ "$status" -eq 1 ] | ||
} | ||
|
Oops, something went wrong.