From f309f2abc358c57e623dd6ff226d7b6cb3937fd4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Mon, 21 Sep 2026 22:19:05 -1000 Subject: Unify the docs, samples and extensions --- custom/hooks/post-receive.cgit-cache | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'custom/hooks/post-receive.cgit-cache') diff --git a/custom/hooks/post-receive.cgit-cache b/custom/hooks/post-receive.cgit-cache index 21550a9..148a3f3 100755 --- a/custom/hooks/post-receive.cgit-cache +++ b/custom/hooks/post-receive.cgit-cache @@ -1,36 +1,33 @@ #!/bin/sh -# -# Example hook that drops cgit's output cache after a push, so new commits -# show up right away instead of once the cache-*-ttl minutes have passed. -# -# This only matters when cache-size in your cgitrc is above 0, which turns -# the cache on. + +# Drops cgit's output cache after a push, so new commits show up right away +# instead of once the cache-*-ttl minutes have passed. It only matters when +# cache-size in cgitrc is above 0, which turns the cache on. # # cgit names each cache slot after a hash of the request url, so there is no # way to expire one repository's pages on their own and this clears the lot. -# cgit refills a slot the next time something asks for it. The cached +# cgit refills a slot the next time something asks for it. The cached # repository scan goes too, which is what makes a brand new repository appear # without waiting out cache-scan-ttl. # -# This hook assumes the default cache-root of "/var/cache/cgit". If you -# change the value in your cgitrc then you must also change it here. -# -# The web server owns the cache root, so the pushing user needs write access -# to it. Nothing here exits nonzero when that access is missing, so the -# pusher is not shown an error over a stale page. -# -# To install the hook, copy (or link) it to the file "hooks/post-receive" in -# each of your repositories. Git runs one post-receive per repository, so -# fold this together with the agefile hook if you want both. +# The path below is the default cache-root, so a cgitrc that changes the +# setting needs the same change here. The web server owns the cache root, so +# the pushing user needs write access to it. Nothing here exits nonzero when +# that access is missing, so the pusher is not shown an error over a stale +# page. # +# To install the hook, copy or link it to hooks/post-receive in each +# repository. Git runs one post-receive per repository, so fold this together +# with the age-file hook to have both. set -eu cache_root=/var/cache/cgit -[ -d "$cache_root" ] || exit 0 +test -d "$cache_root" || exit 0 # Everything directly under the cache root is a cache file, so the only thing # worth keeping is the lock files, which belong to writers still working. # The "! -name . -prune" pair is how POSIX find stays out of subdirectories. -find "$cache_root"/. ! -name . -prune ! -name '*.lock' -type f -exec rm -f {} + || exit 0 +find "$cache_root"/. ! -name . -prune ! -name '*.lock' -type f \ + -exec rm -f {} + || exit 0 -- cgit v2.8.0