Drop --insane flag, just formulate the prompt appropriately

This commit is contained in:
Martin von Gagern 2017-01-13 13:48:25 +01:00
parent 5783e193ed
commit 5e4f50dc09

View File

@ -8,7 +8,7 @@ NEXT_VERSION=
BRANCH=$(git rev-parse --abbrev-ref HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD)
NARGS=0 NARGS=0
DRY_RUN= DRY_RUN=
INSANE="exit 1" INSANE=0
# usage [ERROR-MESSAGES...] EXIT-STATUS # usage [ERROR-MESSAGES...] EXIT-STATUS
usage() { usage() {
@ -21,7 +21,6 @@ usage() {
echo "" echo ""
echo "Options:" echo "Options:"
echo " --dry-run|-n: only print commands, do not execute them." echo " --dry-run|-n: only print commands, do not execute them."
echo " --insane: skip sanity checks, use at your own risk."
echo "" echo ""
echo "Examples:" echo "Examples:"
echo " When releasing a new point release:" echo " When releasing a new point release:"
@ -38,9 +37,6 @@ while [ $# -gt 0 ]; do
git() { echo "git $*"; } git() { echo "git $*"; }
npm() { echo "npm $*"; } npm() { echo "npm $*"; }
;; ;;
--insane)
INSANE="echo Continuing despite failed sanity check"
;;
-h|-\?|--help) -h|-\?|--help)
usage 0 usage 0
;; ;;
@ -73,24 +69,28 @@ fi
# Some sanity checks up front # Some sanity checks up front
if ! command git diff --stat --exit-code HEAD; then if ! command git diff --stat --exit-code HEAD; then
echo "Please make sure you have no uncommitted changes" >&2 echo "Please make sure you have no uncommitted changes" >&2
$INSANE : $((++INSANE))
fi fi
if ! command npm owner ls katex | grep -q "^$(command npm whoami) <"; then if ! command npm owner ls katex | grep -q "^$(command npm whoami) <"; then
echo "You don't seem do be logged into npm, use \`npm login\`" >&2 echo "You don't seem do be logged into npm, use \`npm login\`" >&2
$INSANE : $((++INSANE))
fi fi
if [[ $BRANCH != @(v*|master) ]]; then if [[ $BRANCH != @(v*|master) ]]; then
echo "'$BRANCH' does not like a release branch to me" >&2 echo "'$BRANCH' does not like a release branch to me" >&2
$INSANE : $((++INSANE))
fi fi
if [ -z "$NEXT_VERSION" ]; then if [[ -z "$NEXT_VERSION" ]]; then
echo "About to release $VERSION from $BRANCH. " echo "About to release $VERSION from $BRANCH. "
else else
echo "About to release $VERSION from $BRANCH and bump to $NEXT_VERSION-pre." echo "About to release $VERSION from $BRANCH and bump to $NEXT_VERSION-pre."
fi fi
if [[ $INSANE != 0 ]]; then
read -r -p "$INSANE sanity check(s) failed, really proceed? [y/n] " CONFIRM
else
read -r -p "Look good? [y/n] " CONFIRM read -r -p "Look good? [y/n] " CONFIRM
if [ "$CONFIRM" != "y" ]; then fi
if [[ "$CONFIRM" != "y" ]]; then
exit 1 exit 1
fi fi
@ -158,5 +158,4 @@ if [[ ${DRY_RUN} ]]; then
echo "Some files got modified, though, so you might want to undo " echo "Some files got modified, though, so you might want to undo "
echo "these changes now, e.g. using \`git checkout -- .\` or similar." echo "these changes now, e.g. using \`git checkout -- .\` or similar."
echo "" echo ""
command git diff --stat
fi fi