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