Skip to content

Commit

Permalink
feat(please): possibility to release exact version
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Jul 21, 2019
1 parent 12da486 commit a7c0a11
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions please
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ $(ok Options:)
$(info "-p --public") $(comment "Set scoped npm package for public access.")
$(info "-u --update") $(comment "Update ${PLIZ} to latest version.")
$(info "-v --vfile") $(comment "Forces creation of VERSION file.")
$(info "-V --version") $(comment "Forces the exact version to be released.")
$(info "-y --yes") $(comment "Assume yes for any confirmation.")
$(ok Examples:)
Expand All @@ -69,6 +70,7 @@ $(ok Examples:)
please --vfile --chash
please minor --public --yes
please major --vfile --chlog
please --vfile --chlog --chash --version 1.5.0
USAGE
exit 0
}
Expand Down Expand Up @@ -162,6 +164,7 @@ do
-c | --chlog) CHLOG=1; shift 1 ;;
-H | --chash) GCFMT="[%h](https://github.com/${REPO}/commit/%h) ${GCFMT}"; shift 1 ;;
-y | --yes) YES=1; shift 1 ;;
-V | --version) NEXT_VERSION=$2; shift 2 ;;
minor) MINOR=1; shift 1 ;;
major) MAJOR=1; shift 1 ;;
*) error "Invalid arg ${1}. (Run ${PLIZ} --help)"; exit 1 ;;
Expand Down Expand Up @@ -210,21 +213,25 @@ if [ "" == "$COMMITS" ]; then
exit 0
fi

echo $COMMITS >> $TMP_LOG

# determine next version
FEAT=`git log ${DIFF} --oneline --pretty="%s" | grep -P '^feat' || echo ""`
if [[ $MAJOR -eq 1 ]]; then
V=""
if [[ $VERSION == v* ]]; then
V="v"
VERSION="${VERSION//v/}"
if [[ "" = "$NEXT_VERSION" ]]; then
FEAT=`git log ${DIFF} --oneline --pretty="%s" | grep -P '^feat' || echo ""`
if [[ $MAJOR -eq 1 ]]; then
V=""
if [[ $VERSION == v* ]]; then
V="v"
VERSION="${VERSION//v/}"
fi
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $V$((a + 1)).0.0)`
elif [[ $MINOR -eq 1 ]]; then
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $a.$((b + 1)).0)`
elif [[ "" != "$FEAT" ]]; then
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $a.$((b + 1)).0)`
else
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $a.$b.$((c + 1)))`
fi
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $V$((a + 1)).0.0)`
elif [[ $MINOR -eq 1 ]]; then
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $a.$((b + 1)).0)`
elif [[ "" != "$FEAT" ]]; then
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $a.$((b + 1)).0)`
else
NEXT_VERSION=`echo $VERSION | (IFS=".$IFS"; read a b c && echo $a.$b.$((c + 1)))`
fi

if [[ $YES -eq 0 ]]; then
Expand Down

0 comments on commit a7c0a11

Please sign in to comment.