stagit-fork

My forked version of stagit I made for noobs
git clone git://shipwreckt.co.uk/stagit-fork.git
Log | Files | Refs | README | LICENSE

example_post-receive.sh (2054B)


      1 #!/bin/sh
      2 # Git post-rreceive hook to update stagit when there is a git commit.
      3 # This will work on all of your git repos.
      4 #
      5 # Add this file to your git repo
      6 # /srv/git/<repo name>.git/hooks/post-receive
      7 #
      8 # Make sure the Git user has access to your website files so the hook will work!
      9 #
     10 # usage: $0 [name]
     11 #
     12 # if name is not set the basename of the current directory is used,
     13 # this is the directory of the repo when called from the post-receive script.
     14 
     15 # NOTE: needs to be set for correct locale (expects UTF-8) otherwise the
     16 #       default is LC_CTYPE="POSIX".
     17 export LC_CTYPE="en_US.UTF-8"
     18 
     19 name="$1"
     20 if test "${name}" = ""; then
     21     name=$(basename "$(pwd)")
     22 fi
     23 
     24 # config
     25 # paths must be absolute.
     26 
     27 # Reposdir is the directory your git repos are located
     28 reposdir="/srv/git"
     29 dir="${reposdir}/${name}"
     30 # htmldir is where your stagit static site is located
     31 htmldir="/var/www/git/htmldir"
     32 stagitdir="/"
     33 destdir="${htmldir}${stagitdir}"
     34 cachefile=".htmlcache"
     35 # /config
     36 
     37 if ! test -d "${dir}"; then
     38     echo "${dir} does not exist" >&2
     39     exit 1
     40 fi
     41 cd "${dir}" || exit 1
     42 
     43 # detect git push -f
     44 force=0
     45 while read -r old new ref; do
     46     test "${old}" = "0000000000000000000000000000000000000000" && continue
     47     test "${new}" = "0000000000000000000000000000000000000000" && continue
     48 
     49     hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
     50     if test -n "${hasrevs}"; then
     51         force=1
     52         break
     53     fi
     54 done
     55 
     56 # strip .git suffix.
     57 r=$(basename "${name}")
     58 d=$(basename "${name}" ".git")
     59 printf "[%s] stagit HTML pages... " "${d}"
     60 
     61 mkdir -p "${destdir}/${d}"
     62 cd "${destdir}/${d}" || exit 1
     63 
     64 # remove commits and ${cachefile} on git push -f, this recreated later on.
     65 if test "${force}" = "1"; then
     66     rm -f "${cachefile}"
     67     rm -rf "commit"
     68 fi
     69 
     70 # make index.
     71 stagit-index "${reposdir}/"*/ > "${destdir}/index.html"
     72 
     73 # make pages.
     74 # Replace with your domain name please
     75 stagit -c "${cachefile}" -u "https://yourwebsite.com/$d/" "${reposdir}/${r}"
     76 
     77 ln -sf log.html index.html
     78 ln -sf ../style.css style.css
     79 ln -sf ../logo.png logo.png
     80 
     81 echo "done"
     82