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!
11 # Make sure the current directory is where we expect to be
12 [ "${GIT_DIR+set}" != "set" ] ||
{ [ -n "$GIT_DIR" ] && [ -d "$GIT_DIR" ]; } ||
unset GIT_DIR
13 [ -n "$GIT_DIR" ] || GIT_DIR
="$(git rev-parse --git-dir)"
14 [ -n "$GIT_DIR" ] && cd -P "${GIT_DIR:-.}" ||
exit 1
15 case "${PWD%/*}" in */worktrees
)
18 # But it COULD just be a coincidence...
19 [ -s commondir
] && [ -s HEAD
] &&
20 _cmndir
= && read -r _cmndir
<commondir
2>/dev
/null
&&
21 [ -n "$_cmndir" ] && [ -d "$_cmndir" ]
23 # ...it is not, fix it!
24 cd -P "$_cmndir" ||
exit 1
27 GIT_DIR
="." GIT_PREFIX
= && export GIT_DIR
30 case "$PWD" in *?
/mob
)
32 GIROCCO_PERSONAL_MOB
=1
36 autogchack
=@autogchack@
38 git config gitweb.lastchange
"$(date '+%a, %d %b %Y %T %z')" ||
:
39 git for-each-ref
--sort=-committerdate --format='%(committerdate:iso8601)' \
40 --count=1 refs
/heads
>info
/lastactivity ||
:
41 ! [ -d htmlcache
] ||
{ >htmlcache
/changed
; } 2>/dev
/null ||
:
42 rm -f .delaygc .allowgc
43 if [ "$mob" = "mob" ] && [ -d mob
]; then
44 git for-each-ref
--format='%(objectname) %(refname)' >packed-refs.mob.$$ ||
:
45 mv -f packed-refs.mob.$$ packed-refs.mob
46 rm -f packed-refs.mob.$$
49 sockpath
=/etc
/taskd.socket
51 if [ -x @perlbin@
]; then
55 sockpath
="$cfg_chroot$sockpath"
56 v_get_proj_from_dir projname
58 # authuser needs to be set if not running in the chroot.
59 # Currently that can only be the case with https push in
60 # which case REMOTE_USER will contain the user name (possibly prefixed
61 # with "/UID=" and suffixed with "/dnQualifier=...").
62 # Fallback is the mirror_user if REMOTE_USER is not set.
63 authuser
="${REMOTE_USER#/UID=}"
64 authuser
="${authuser#UID = }"
65 authuser
="${authuser%/dnQualifier=*}"
66 authuser
="${authuser%, dnQualifier = *}"
67 [ -n "$authuser" ] || authuser
="%$cfg_mirror_user%"
70 reporoot
=/@jailreporoot@
71 reporoot
="$(cd "$reporoot" && pwd -P)"
73 projname
="${cwd#$reporoot/}"
75 nc_openbsd
() { /bin
/nc.openbsd
"$@"; }
79 [ "${autogchack:-0}" != "0" ] &&
80 { [ "$cfg_autogchack" != "mirror" ] ||
! [ -e .nofetch
]; } &&
81 [ "$(git config --get --bool girocco.autogchack 2>/dev/null)" != "false" ]
83 git for-each-ref
--format '%(refname) %(objectname)' | LC_ALL
=C
sort -b -k1,1 >.refs-new.$$
84 mv -f .refs-new.$$ .refs-last
88 if [ -n "$GIROCCO_PERSONAL_MOB" ] ||
! [ -S "$sockpath" ]; then
89 # We never run the ref update notification part on a personal mob push
90 # Read the incoming refs, but just ignore them (git doesn't like SIGPIPE)
91 while read -r line
; do
97 echo "ref-changes $authuser ${projname%.git}" ||
:
98 while read -r line
; do
101 git for-each-ref
--format='%(objectname) %(objectname) %(refname)' refs
/heads ||
:
102 echo "done ref-changes $authuser ${projname%.git}" ||
:
103 ) 2>/dev
/null |
{ nc_openbsd
-w 15 -U "$sockpath" ||
:; } ||
: