From 627158845b55db76fbd612d5d54014c3825a159a Mon Sep 17 00:00:00 2001 From: Christian Marie Date: Mon, 6 Jul 2015 17:05:45 +1000 Subject: [PATCH] Make bump-versions.sh work This also makes it behave when called from from any directory. --- scripts/bump-versions.sh | 10 +++++++--- scripts/lib/common.sh | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/bump-versions.sh b/scripts/bump-versions.sh index f75a3d5e..e1e735f4 100755 --- a/scripts/bump-versions.sh +++ b/scripts/bump-versions.sh @@ -16,7 +16,8 @@ set -o nounset set -o errexit -. lib/common.sh +DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )) +. "${DIR}/scripts/lib/common.sh" usage () { echo " bump-versions.sh [-d|--dry-run]" @@ -54,8 +55,11 @@ while [ "${1:-unset}" != "unset" ] ; do done if $DRY_RUN ; then - bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}") + echo "Would have bumped position ${POSITION} on these packages:" + ( cd "$ROOT" && bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}") ) else - bumper -"$POSITION" $(join , "${SOURCES[@]}") + ( cd "$ROOT" && bumper -"$POSITION" $(join , "${SOURCES[@]}") ) fi +# Trailing newline, bumper does not ship with its own. +echo diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index bbf3a25a..6cdb8fbe 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -11,6 +11,7 @@ DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )) +ROOT=$( dirname $DIR ) DRY_RUN=false POSITION="none" SOURCES_TXT="$( dirname $DIR)/sources.txt" @@ -23,7 +24,7 @@ readarray -t SOURCES < "$SOURCES_TXT" join () { local IFS="$1"; shift; echo "$*"; } versions_equal () { - local NUM=$(find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l) + local NUM=$(cd "$ROOT" && find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l) if [ 1 -eq $NUM ] ; then return 0 else