Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
✏️ Use PREV_VERSION as it better describes itself
Browse files Browse the repository at this point in the history
  • Loading branch information
jamieconnolly committed Jun 28, 2017
1 parent b3553d6 commit 18de312
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libexec/handles-release
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ elif [ "$(git rev-list --count HEAD..origin/master)" != "0" ]; then
exit 1
fi

CURRENT_VERSION="$(git describe --tags --abbrev=0 --match='v[0-9]*' 2>/dev/null || true)"
PREV_VERSION="$(git describe --tags --abbrev=0 --match='v[0-9]*' 2>/dev/null || true)"
VERSION_REGEX="^v(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))?)?$"

if [[ "$CURRENT_VERSION" =~ $VERSION_REGEX ]]; then
if [[ "$PREV_VERSION" =~ $VERSION_REGEX ]]; then
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[3]}"
PATCH="${BASH_REMATCH[5]}"
elif [ -z "$CURRENT_VERSION" ]; then
elif [ -z "$PREV_VERSION" ]; then
MAJOR="0"
MINOR="0"
PATCH="0"
Expand All @@ -53,7 +53,7 @@ if [[ ! "$VERSION" =~ $VERSION_REGEX ]]; then
elif git describe --exact-match "$VERSION" &>/dev/null; then
echo "!!! Error: ${VERSION} tag already exists" >&2
exit 1
elif [ -n "$CURRENT_VERSION" ] && [ "$(git rev-list --count "$CURRENT_VERSION"..HEAD)" == "0" ]; then
elif [ -n "$PREV_VERSION" ] && [ "$(git rev-list --count "$PREV_VERSION"..HEAD)" == "0" ]; then
echo "!!! Error: there are no commits to release" >&2
exit 1
fi
Expand All @@ -77,8 +77,8 @@ if [ -f "CHANGELOG.md" ] && ! grep -q "^# ${VERSION}" CHANGELOG.md &>/dev/null;

printf "# %s - %s\n\n" "$VERSION" "$(date +"%d %b %Y")" > CHANGELOG.tmp

if [ -n "$CURRENT_VERSION" ]; then
git log --reverse --no-merges --format='- %s' "$CURRENT_VERSION"..HEAD | grep -v ":bookmark:"
if [ -n "$PREV_VERSION" ]; then
git log --reverse --no-merges --format='- %s' "$PREV_VERSION"..HEAD | grep -v ":bookmark:"
else
echo "- :tada: Initial release"
fi >> CHANGELOG.tmp
Expand Down

0 comments on commit 18de312

Please sign in to comment.