#!/bin/bash unset GIT_DIR SELF=deploy-hooks.git REPO_DIR=$HOME/repositories CHECKOUT_DIR=$HOME/local/checkouts/deploy-hooks case $1 in refs/heads/master) echo "Updating hooks on vcs.fsf.org..." ;; *) echo 'No rules for this branch!' exit 0 ;; esac echo "Updating local checkout..." if [ ! -d $CHECKOUT_DIR ]; then git clone $REPO_DIR/$SELF $CHECKOUT_DIR git checkout stable else cd $CHECKOUT_DIR git pull origin stable fi echo "Syncing hooks..." for working_copy in $(find $CHECKOUT_DIR -maxdepth 1 -name '*.git' -type d | grep -v '/.git'); do echo Updating remote hooks for: ${working_copy//*\//}/hooks/ rsync -avrSPX --delete $working_copy/* $REPO_DIR/${working_copy//*\//}/hooks/ done exec git update-server-info