girocco: support fetching bundles
[girocco.git] / hooks / post-receive
blob3a54a9780dfc1cfb8939ddad23e96bcb8cd1c01b
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 rm -f .delaygc .allowgc
18 if [ "$mob" = "mob" -a -d mob ]; then
19 git for-each-ref --format='%(objectname) %(refname)' > packed-refs.mob.$$ || :
20 mv -f packed-refs.mob.$$ packed-refs.mob
21 rm -f packed-refs.mob.$$
24 sockpath=/etc/taskd.socket
25 reporoot=/@jailreporoot@
26 authuser="$LOGNAME"
27 cwd="$(pwd)"
28 if [ -x /usr/bin/perl ]; then
29 # Not in chroot...
30 . @basedir@/shlib.sh
32 sockpath="$cfg_chroot$sockpath"
33 reporoot="$cfg_reporoot"
35 # authuser needs to be set if not running in the chroot.
36 # Currently that can only be the case with https push in
37 # which case REMOTE_USER will contain the user name (possibly prefixed
38 # with "/UID=" and suffixed with "/dnQualifier=...").
39 # Fallback is the mirror_user if REMOTE_USER is not set.
40 authuser="${REMOTE_USER#/UID=}"
41 authuser="${authuser%/dnQualifier=*}"
42 [ -n authuser ] || authuser="$cfg_mirror_user"
43 else
44 # In chroot...
45 nc_openbsd() { /bin/nc.openbsd "$@"; }
47 projname="${cwd#$reporoot/}"
49 if [ -n "$GIROCCO_PERSONAL_MOB" ] || ! [ -S "$sockpath" ]; then
50 # We never run the ref update notification part on a personal mob push
51 # Read the incoming refs, but just ignore them (git doesn't like SIGPIPE)
52 while read -r line; do
54 done
55 else
56 while read -r line; do
57 echo "ref-change $authuser ${projname%.git} $line" | nc_openbsd -w 1 -U "$sockpath" || :
58 done
61 exit 0