#!/bin/sh # This gitolite3 hook exports content for web publishing. # The following gitolite3 environment variables affect its use: # WEB_BRANCH tree-ish (hook silently skipped if unset) # WEB_BASEDIR path writable by gitolite3 (default: /var/www/gitolite3) # WEB_EXEC_INIT command executed in exported dir after initial checkout # WEB_EXEC command executed in exported dir after every checkout set -eu WEB_BRANCH=${GL_OPTION_WEB_BRANCH:-} WEB_EXEC=${GL_OPTION_WEB_EXEC:-} WEB_EXEC_INIT=${GL_OPTION_WEB_EXEC_INIT:-} [ -n "$WEB_BRANCH" ] || exit 0 WEB_BASEDIR=${GL_OPTION_WEB_BASEDIR:-/var/www/gitolite3} GIT_WORK_TREE="$WEB_BASEDIR/$GL_REPO" if [ -e "$GIT_WORK_TREE" ]; then echo "Refreshing content in $GIT_WORK_TREE ..." git -C "$GIT_WORK_TREE" checkout -f "$WEB_BRANCH" chmod -R u=rw,go=r,a+X "$GIT_WORK_TREE" else echo "Checking out content to $GIT_WORK_TREE ..." git -C "$WEB_BASEDIR" clone --quiet --branch "$WEB_BRANCH" "$PWD" chmod -R u=rw,go=r,a+X "$GIT_WORK_TREE" if [ -n "$WEB_EXEC_INIT" ]; then ( cd "$GIT_WORK_TREE" && echo "$WEB_EXEC_INIT" | sh - ) fi fi if [ -n "$WEB_EXEC" ]; then ( cd "$GIT_WORK_TREE" && echo "$WEB_EXEC" | sh - ) fi echo "Checkout completed succesfully!"