tags: explicitly white list a few tags
[girocco.git] / hooks / post-receive
blob673d693cecf1b9d2678f957c64c2f29fabdb4da4
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 -P)"
28 if [ -x @perlbin@ ]; 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 reporoot="$(cd "$reporoot" && pwd -P)"
48 projname="${cwd#$reporoot/}"
50 if [ -n "$GIROCCO_PERSONAL_MOB" ] || ! [ -S "$sockpath" ]; then
51 # We never run the ref update notification part on a personal mob push
52 # Read the incoming refs, but just ignore them (git doesn't like SIGPIPE)
53 while read -r line; do
55 done
56 else
58 trap ':' PIPE
59 echo "ref-changes $authuser ${projname%.git}" || :
60 while read -r line; do
61 printf '%s\n' "$line" || :
62 done
63 ) 2>/dev/null | { nc_openbsd -w 15 -U "$sockpath" || :; }
66 exit 0