diff options
Diffstat (limited to 'example_post-receive.sh')
-rwxr-xr-x | example_post-receive.sh | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/example_post-receive.sh b/example_post-receive.sh index 5e8d32b..6a91057 100755 --- a/example_post-receive.sh +++ b/example_post-receive.sh @@ -1,7 +1,9 @@ #!/bin/sh -# generic git post-receive hook. -# change the config options below and call this script in your post-receive -# hook or symlink it. +# Git post-rreceive hook to update stagit when there is a git commit. +# This will work on all of your git repos. +# +# Add this file to your git repo +# /srv/git/<repo name>.git/hooks/post-receive # # usage: $0 [name] # @@ -14,36 +16,39 @@ export LC_CTYPE="en_US.UTF-8" name="$1" if test "${name}" = ""; then - name=$(basename "$(pwd)") + name=$(basename "$(pwd)") fi # config # paths must be absolute. -reposdir="/home/src/src" + +# Reposdir is the directory your git repos are located +reposdir="/srv/git" dir="${reposdir}/${name}" -htmldir="/home/www/domains/git.codemadness.org/htdocs" +# htmldir is where your stagit static site is located +htmldir="/var/www/git/htmldir" stagitdir="/" destdir="${htmldir}${stagitdir}" cachefile=".htmlcache" # /config if ! test -d "${dir}"; then - echo "${dir} does not exist" >&2 - exit 1 + echo "${dir} does not exist" >&2 + exit 1 fi cd "${dir}" || exit 1 # detect git push -f force=0 while read -r old new ref; do - test "${old}" = "0000000000000000000000000000000000000000" && continue - test "${new}" = "0000000000000000000000000000000000000000" && continue + test "${old}" = "0000000000000000000000000000000000000000" && continue + test "${new}" = "0000000000000000000000000000000000000000" && continue - hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q) - if test -n "${hasrevs}"; then - force=1 - break - fi + hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q) + if test -n "${hasrevs}"; then + force=1 + break + fi done # strip .git suffix. @@ -56,18 +61,20 @@ cd "${destdir}/${d}" || exit 1 # remove commits and ${cachefile} on git push -f, this recreated later on. if test "${force}" = "1"; then - rm -f "${cachefile}" - rm -rf "commit" + rm -f "${cachefile}" + rm -rf "commit" fi # make index. stagit-index "${reposdir}/"*/ > "${destdir}/index.html" # make pages. -stagit -c "${cachefile}" -u "https://git.codemadness.nl/$d/" "${reposdir}/${r}" +# Replace with your domain name please +stagit -c "${cachefile}" -u "https://yourwebsite.com/$d/" "${reposdir}/${r}" ln -sf log.html index.html ln -sf ../style.css style.css ln -sf ../logo.png logo.png echo "done" + |