#!/bin/sh # - place this file in the 'hooks' directory of a bare git repository # - this assumes that repo2html is in your path # The toplevel path containing directories of static pages [ "$REPO2HTML_PREFIX" ] || export REPO2HTML_PREFIX=/var/www/git # The toplevel clone url for repos. export REPO2HTML_CLONE_URL=git://git.example.com export REPO2HTML_TITLE=git.example.com export REPO2HTML_DESCRIPTION="sherry's git repositories" export REPO2HTML_H1=git.example.com # hueristic attempt to detect a reasonable default for the name of this repo # you may want to adjust this if you have e.g. sub-directories containing repos # whose structure you want to preserve on the webserver. if repo_name="$(git config repo2html.dirname)"; then : # repo name from git config; do nothing else elif [ "$(git rev-parse --is-bare-repository)" = "true" ]; then # bare /foo/bar/baz/myrepo.git -> myrepo repo_name="$(basename "$(pwd)" .git)" git config repo2html.dirname "$repo_name" else # /foo/bar/baz/myrepo/.git -> myrepo repo_name="$(basename "$(dirname "$(pwd)")")" git config repo2html.dirname "$repo_name" fi # only generate if default branch is modified headref="$(git symbolic-ref -q HEAD)" while read -r _ _ ref do [ "$ref" = "$headref" ] && go=1 done if [ "$go" ]; then echo "$headref was updated; regenerating HTML at: $REPO2HTML_PREFIX/$repo_name" else echo "($headref was not updated so HTML will not be regenerated.)" exit 0 fi # check to see if we can even write to the specified directory if mkdir -p "$REPO2HTML_PREFIX/$repo_name" && \ [ -x "$REPO2HTML_PREFIX/$repo_name" ] && \ [ -w "$REPO2HTML_PREFIX/$repo_name" ] then : # we can write to the directory; seems good else echo "Error: can't generate HTML due to insufficient permissions on path:" echo " $REPO2HTML_PREFIX/$repo_name" echo "Set REPO2HTML_PREFIX in the environment or this script:" echo " $0" exit 1 fi repo2html "$REPO2HTML_PREFIX/$repo_name"