From: dsc Date: Tue, 21 Feb 2012 22:27:38 +0000 (-0800) Subject: Script to update another repo's hooks post-update. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=32d248f494d75a5b0557ae35bc60c6e9f4e68353;p=kraken-ui-hooks.git Script to update another repo's hooks post-update. --- diff --git a/update-hooks-post-update.sh b/update-hooks-post-update.sh new file mode 100755 index 0000000..648026d --- /dev/null +++ b/update-hooks-post-update.sh @@ -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!"