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 if ! [ -x @perlbin@
]; then
12 # We are INSIDE the chroot
13 PATH
=/bin
&& export PATH
16 # Make sure the current directory is where we expect to be
17 [ "${GIT_DIR+set}" != "set" ] ||
{ [ -n "$GIT_DIR" ] && [ -d "$GIT_DIR" ]; } ||
unset GIT_DIR
18 [ -n "$GIT_DIR" ] || GIT_DIR
="$(git rev-parse --git-dir)"
19 [ -n "$GIT_DIR" ] && cd -P "${GIT_DIR:-.}" ||
exit 1
20 case "${PWD%/*}" in */worktrees
)
23 # But it COULD just be a coincidence...
24 [ -s commondir
] && [ -s HEAD
] &&
25 _cmndir
= && read -r _cmndir
<commondir
2>/dev
/null
&&
26 [ -n "$_cmndir" ] && [ -d "$_cmndir" ]
28 # ...it is not, fix it!
29 cd -P "$_cmndir" ||
exit 1
32 GIT_DIR
="." GIT_PREFIX
= && export GIT_DIR
35 case "$PWD" in *?
/mob
)
37 GIROCCO_PERSONAL_MOB
=1
41 autogchack
=@autogchack@
43 git config gitweb.lastchange
"$(date '+%a, %d %b %Y %T %z')" ||
:
44 git for-each-ref
--sort=-committerdate --format='%(committerdate:iso8601)' \
45 --count=1 refs
/heads
>info
/lastactivity ||
:
46 ! [ -d htmlcache
] ||
{ >htmlcache
/changed
; } 2>/dev
/null ||
:
47 rm -f .delaygc .allowgc
48 if [ "$mob" = "mob" ] && [ -d mob
]; then
49 git for-each-ref
--format='%(objectname) %(refname)' >packed-refs.mob.$$ ||
:
50 mv -f packed-refs.mob.$$ packed-refs.mob
51 rm -f packed-refs.mob.$$
54 sockpath
=/etc
/taskd.socket
56 if [ -x @perlbin@
]; then
57 # We are NOT inside the chroot
60 sockpath
="$cfg_chroot$sockpath"
61 v_get_proj_from_dir projname
63 # authuser needs to be set if not running in the chroot.
64 # Currently that can only be the case with https push in
65 # which case REMOTE_USER will contain the user name (possibly prefixed
66 # with "/UID=" and suffixed with "/dnQualifier=...").
67 # Fallback is the mirror_user if REMOTE_USER is not set.
68 authuser
="${REMOTE_USER#/UID=}"
69 authuser
="${authuser#UID = }"
70 authuser
="${authuser%/dnQualifier=*}"
71 authuser
="${authuser%, dnQualifier = *}"
72 [ -n "$authuser" ] || authuser
="%$cfg_mirror_user%"
75 reporoot
=/@jailreporoot@
76 reporoot
="$(cd "$reporoot" && pwd -P)"
78 projname
="${cwd#$reporoot/}"
80 nc_openbsd
() { /bin
/nc.openbsd
"$@"; }
84 [ "${autogchack:-0}" != "0" ] &&
85 { [ "$cfg_autogchack" != "mirror" ] ||
! [ -e .nofetch
]; } &&
86 [ "$(git config --get --bool girocco.autogchack 2>/dev/null)" != "false" ]
88 git for-each-ref
--format '%(refname) %(objectname)' | LC_ALL
=C
sort -b -k1,1 >.refs-new.$$
89 mv -f .refs-new.$$ .refs-last
93 if [ -n "$GIROCCO_PERSONAL_MOB" ] ||
! [ -S "$sockpath" ]; then
94 # We never run the ref update notification part on a personal mob push
95 # Read the incoming refs, but just ignore them (git doesn't like SIGPIPE)
96 while read -r line
; do
100 # Check to see if we've lost our HEAD
101 if ! git rev-parse
--verify HEAD
>/dev
/null
2>&1; then
102 git config
--unset girocco.headok
>/dev
/null
2>&1 ||
:
106 echo "ref-changes $authuser ${projname%.git}" ||
:
107 while read -r line
; do
110 git for-each-ref
--format='%(objectname) %(objectname) %(refname)' refs
/heads ||
:
111 echo "done ref-changes $authuser ${projname%.git}" ||
:
112 ) 2>/dev
/null |
{ nc_openbsd
-w 15 -U "$sockpath" ||
:; } ||
: