First attempt at version application script
authorThomas Berezansky <tsbere@mvlc.org>
Thu, 19 May 2011 18:18:08 +0000 (14:18 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Thu, 19 May 2011 18:18:08 +0000 (14:18 -0400)
Usage:
Create/Checkout new branch
    AKA, #.#-beta# or #.#.#
Run build/tools/apply_version.sh
git commit -as to save changes.

Can be told what version to use instead via first command line option.
Uses current branch name for "HeadURL" and auto-version checks.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
build/tools/apply_version.sh [new file with mode: 0755]

diff --git a/build/tools/apply_version.sh b/build/tools/apply_version.sh
new file mode 100755 (executable)
index 0000000..91731a9
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+GIT_ABS=`git rev-parse --show-toplevel`
+GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
+HEADURL="http://git.evergreen-ils.org/Evergreen.git?h=refs/heads/$GIT_BRANCH"
+
+VERSION=${1:-AUTO}
+
+if [ $VERSION = "AUTO" ]; then
+    # Auto-pick version based on branch name
+    echo AUTO VERSION
+    VERSION=`echo $GIT_BRANCH | sed 's/^rel_\([0-9]\+\)_\([0-9]\+\)_\([0-9]\+\)$/\1.\2.\3/'`
+    VERSION=`echo $VERSION | sed 's/^rel_\([0-9]\+\)_\([0-9]\+\)_\(.\+\)$/\1.\2-\3/'`
+    if [ "$VERSION" = "$GIT_BRANCH" ]; then
+        echo "AUTO VERSION FAILED."
+        exit 1
+    fi
+fi
+SHORT_VERSION=`echo $VERSION | grep -o '^[0-9]\+\.[0-9]\+'`
+echo "Version: $VERSION Short: $SHORT_VERSION"
+
+# prep a couple alternate represenations
+DASH_VERSION=`echo $VERSION | sed 's/\./-/g'`
+UNDER_VERSION=`echo $VERSION | sed -e 's/\./_/g' -e 's/-/_/g'`
+
+echo "Applying to Application.pm - HEAD -> $DASH_VERSION"
+sed -i "s/HEAD/$DASH_VERSION/" $GIT_ABS/Open-ILS/src/perlmods/lib/OpenILS/Application.pm
+
+echo "Applying to windowssetup.nsi - Master -> $SHORT_VERSION"
+sed -i "s/Master/$SHORT_VERSION/" $GIT_ABS/Open-ILS/xul/staff_client/windowssetup.nsi
+
+echo "Applying to README:"
+echo "Header with $VERSION"
+echo "STAMP_ID with $UNDER_VERSION"
+sed -i -e "1 s/Evergreen.*/Evergreen $VERSION/" -e "s/STAMP_ID=rel_[^ ]*/STAMP_ID=rel_$UNDER_VERSION/" $GIT_ABS/README
+
+echo "Applying \$HeadURL\$ - $HEADURL"
+for file in `grep -Rl '\\$HeadURL\\$' $GIT_ABS`;
+do
+    echo $file
+    sed -i "s|\\\$HeadURL\\\$|$HEADURL|" $file
+done