2 # generic git post-receive hook.
3 # change the config options below and call this script in your post-receive
8 # if name is not set the basename of the current directory is used,
9 # this is the directory of the repo when called from the post-receive script.
11 # NOTE: needs to be set for correct locale (expects UTF-8) otherwise the
12 # default is LC_CTYPE="POSIX".
13 export LC_CTYPE="en_US.UTF-8"
16 if test "${name}" = ""; then
17 name=$(basename "$(pwd)")
21 # paths must be absolute.
22 reposdir="/home/src/src"
23 dir="${reposdir}/${name}"
24 htmldir="/home/www/domains/git.codemadness.org/htdocs"
26 destdir="${htmldir}${stagitdir}"
27 cachefile=".htmlcache"
30 if ! test -d "${dir}"; then
31 echo "${dir} does not exist" >&2
38 while read -r old new ref; do
39 test "${old}" = "0000000000000000000000000000000000000000" && continue
40 test "${new}" = "0000000000000000000000000000000000000000" && continue
42 hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
43 if test -n "${hasrevs}"; then
50 r=$(basename "${name}")
51 d=$(basename "${name}" ".git")
52 printf "[%s] stagit HTML pages... " "${d}"
54 mkdir -p "${destdir}/${d}"
55 cd "${destdir}/${d}" || exit 1
57 # remove commits and ${cachefile} on git push -f, this recreated later on.
58 if test "${force}" = "1"; then
64 stagit-index "${reposdir}/"*/ > "${destdir}/index.html"
67 stagit -c "${cachefile}" "${reposdir}/${r}"
69 ln -sf log.html index.html
70 ln -sf ../style.css style.css
71 ln -sf ../logo.png logo.png