From 5e4f50dc09b8d85174abfab90501ac2ebf90e516 Mon Sep 17 00:00:00 2001 From: Martin von Gagern Date: Fri, 13 Jan 2017 13:48:25 +0100 Subject: [PATCH] Drop --insane flag, just formulate the prompt appropriately --- release.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/release.sh b/release.sh index 90a931d..809a6a8 100755 --- a/release.sh +++ b/release.sh @@ -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