on master help sign in
Make bump-versions.sh work

This also makes it behave when called from from any directory.

commit1efe9f1a2ae6128d152c2ebdadf5d8a9e8a72871 authorChristian Marie <christian@ponies.io> dateMon 6 Jul 2015, 17:05 (11 years ago) parente3c3ba2
2 files changed+9−4
scripts/bump-versions.sh+7−3 scripts/lib/common.sh+2−1
scripts/bump-versions.sh+7−3
@@ -16,7 +16,8 @@
1616set -o nounset
1717set -o errexit
1818
19−. lib/common.sh
19+DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
20+. "${DIR}/scripts/lib/common.sh"
2021
2122usage () {
2223 echo " bump-versions.sh <POSITION> [-d|--dry-run]"
@@ -54,8 +55,11 @@ while [ "${1:-unset}" != "unset" ] ; do
5455done
5556
5657if $DRY_RUN ; then
57− bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}")
58+ echo "Would have bumped position ${POSITION} on these packages:"
59+ ( cd "$ROOT" && bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}") )
5860else
59− bumper -"$POSITION" $(join , "${SOURCES[@]}")
61+ ( cd "$ROOT" && bumper -"$POSITION" $(join , "${SOURCES[@]}") )
6062fi
6163
64+# Trailing newline, bumper does not ship with its own.
65+echo
scripts/lib/common.sh+2−1
@@ -11,6 +11,7 @@
1111
1212
1313DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
14+ROOT=$( dirname $DIR )
1415DRY_RUN=false
1516POSITION="none"
1617SOURCES_TXT="$( dirname $DIR)/sources.txt"
@@ -22,7 +23,7 @@ readarray -t SOURCES < "$SOURCES_TXT"
2223join () { local IFS="$1"; shift; echo "$*"; }
2324
2425versions_equal () {
25− local NUM=$(find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
26+ local NUM=$(cd "$ROOT" && find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
2627 if [ 1 -eq $NUM ] ; then
2728 return 0
2829 else