Switch ref-change to take username instead of uid
[girocco.git] / hooks / post-receive
blob103ecc6c52380e04f55153d4484470fe778bba05
1 #!/bin/sh
3 # Send notification through the taskd socket
5 # Beware, we MAY be running in a chroot!
7 set -e
9 sockpath=/etc/taskd.socket
10 reporoot=/@jailreporoot@
11 authuser="$LOGNAME"
12 cwd="$(pwd)"
13 if [ -x /usr/bin/perl ]; then
14 # Not in chroot...
15 . @basedir@/shlib.sh
17 sockpath="$cfg_chroot$sockpath"
18 reporoot="$cfg_reporoot"
20 # authuser needs to be set if not running in the chroot.
21 # Currently that can only be the case with https push in
22 # which case REMOTE_USER will contain the user name (possibly prefixed
23 # with "/UID="). Fallback is the mirror_user if REMOTE_USER is not set.
24 authuser="${REMOTE_USER#/UID=}"
25 [ -n authuser ] || authuser="$cfg_mirror_user"
27 projname="${cwd#$reporoot/}"
29 [ -S "$sockpath" ] || exit 0
31 while read line; do
32 echo "ref-change $authuser ${projname%.git} $line" | /bin/nc.openbsd -w 1 -U "$sockpath"
33 done
35 exit