post-receive (609B)
1 #!/usr/bin/env bash 2 3 if [ $(git rev-parse --is-bare-repository) = true ]; then 4 REPOSITORY_BASENAME=$(basename "$PWD") 5 else 6 REPOSITORY_BASENAME=$(basename $(readlink -nf "$PWD"/..)) 7 fi 8 9 REPOSITORY_NAME=${REPOSITORY_BASENAME%.git} 10 11 GITDIR="/srv/git" 12 WEBDIR="/var/www/html" 13 14 FORCE=0 15 while read -r old new ref; do 16 HASREVS=$(git rev-list "$old" "^$new" | sed 1q) 17 if test -n "$HASREVS"; then 18 FORCE=1 19 break 20 fi 21 done 22 23 if test "$FORCE" = "1"; then 24 rm -rf "${WEBDIR}/${REPOSITORY_NAME}" 25 fi 26 27 cd /var/www/html || exit 1 28 29 echo '' 30 echo 'generating static pages' 31 ./generate.sh 32 echo ''