Script to update another repo's hooks post-update.
authordsc <david.schoonover@gmail.com>
Tue, 21 Feb 2012 22:27:38 +0000 (14:27 -0800)
committerdsc <david.schoonover@gmail.com>
Tue, 21 Feb 2012 22:27:38 +0000 (14:27 -0800)
update-hooks-post-update.sh [new file with mode: 0755]

diff --git a/update-hooks-post-update.sh b/update-hooks-post-update.sh
new file mode 100755 (executable)
index 0000000..648026d
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+#* udpate-hooks-post-update.sh
+#* Updates and rebuilds another repo's hooks.
+#* 
+
+VERBOSE=1
+TARGET_REPO="kraken-ui"
+HOOKS_REPO="${TARGET_REPO}-hooks"
+CHECKOUTS=~/checkouts
+REPOS=~/repositories
+
+
+# Utilities
+log () { [ "$VERBOSE" ] && echo -e "$*" >&2; }
+fail  () { echo >&2; echo "Error: $*" >&2; exit 1; }
+
+count () { echo $#; }
+nth   () { local n="$1"; shift; [ -z "$n" ] && return 1; [[ "$n" < 0 ]] && n=$(( 1 + $# + $n )); echo "${!n}"; }
+join  () { local sep="$1" old="$IFS"; export IFS=\n; read -t1 out; while read -t1 line; do out="$out$sep$line"; done; echo "$out"; export IFS=$old; }
+
+
+
+
+log "Updating hooks repo (${HOOKS_REPO})...\n"
+{   cd $CHECKOUTS/$HOOKS_REPO &&
+    git fetch --all &&
+    git pull origin master
+} || fail "Problem running fetch & pull on ${HOOKS_REPO}.git!"
+
+log "\nCopying hooks into target repo (${TARGET_REPO})...\n"
+{   log "rsync ./hooks/ $REPOS/${TARGET_REPO}.git/hooks/" &&
+    rsync ./hooks/ $REPOS/${TARGET_REPO}.git/hooks/
+} || fail "Problem rsync-ing hooks to $REPOS/$TARGET_REPO.git/hooks!"
+
+log "\nok!"