tagproj: also touch htmlcache/changed on tag update
[girocco.git] / hooks / post-receive
blob957f403daa812c8de420aba580e1d02cd5c2ff36
1 #!/bin/sh
3 # Keep lastactivity and personal mob (if enabled) up-to-date
4 # We use receive.updateserverinfo=true so no need to run update-server-info
5 # Send notification through the taskd socket if it exists and not personal mob push
7 # Beware, we MAY be running in a chroot!
9 set -e
11 mob=@mob@
12 umask 002
13 git config gitweb.lastchange "$(date '+%a, %d %b %Y %T %z')" || :
14 git for-each-ref --sort=-committerdate --format='%(committerdate:iso8601)' \
15 --count=1 refs/heads > info/lastactivity || :
16 ! [ -d htmlcache ] || { >htmlcache/changed; } 2>/dev/null || :
17 if [ "$mob" = "mob" -a -d mob ]; then
18 git for-each-ref --format='%(objectname) %(refname)' > packed-refs.mob.$$ || :
19 mv -f packed-refs.mob.$$ packed-refs.mob
20 rm -f packed-refs.mob.$$
23 sockpath=/etc/taskd.socket
24 reporoot=/@jailreporoot@
25 authuser="$LOGNAME"
26 cwd="$(pwd)"
27 if [ -x /usr/bin/perl ]; then
28 # Not in chroot...
29 . @basedir@/shlib.sh
31 sockpath="$cfg_chroot$sockpath"
32 reporoot="$cfg_reporoot"
34 # authuser needs to be set if not running in the chroot.
35 # Currently that can only be the case with https push in
36 # which case REMOTE_USER will contain the user name (possibly prefixed
37 # with "/UID=" and suffixed with "/dnQualifier=...").
38 # Fallback is the mirror_user if REMOTE_USER is not set.
39 authuser="${REMOTE_USER#/UID=}"
40 authuser="${authuser%/dnQualifier=*}"
41 [ -n authuser ] || authuser="$cfg_mirror_user"
42 else
43 # In chroot...
44 nc_openbsd() { /bin/nc.openbsd "$@"; }
46 projname="${cwd#$reporoot/}"
48 if [ -n "$GIROCCO_PERSONAL_MOB" ] || ! [ -S "$sockpath" ]; then
49 # We never run the ref update notification part on a personal mob push
50 # Read the incoming refs, but just ignore them (git doesn't like SIGPIPE)
51 while read -r line; do
53 done
54 else
55 while read -r line; do
56 echo "ref-change $authuser ${projname%.git} $line" | nc_openbsd -w 1 -U "$sockpath" || :
57 done
60 exit 0