diff options
context:
space:
mode:
Diffstat (limited to 'custom/hooks')
-rwxr-xr-xcustom/hooks/post-receive.cgit-age25
-rwxr-xr-xcustom/hooks/post-receive.cgit-cache35
2 files changed, 26 insertions, 34 deletions
diff --git a/custom/hooks/post-receive.cgit-age b/custom/hooks/post-receive.cgit-age
index 48b17fc..0567e08 100755
--- a/custom/hooks/post-receive.cgit-age
+++ b/custom/hooks/post-receive.cgit-age
@@ -1,14 +1,9 @@
#!/bin/sh
-#
-# Example hook that updates the "age-file" cgit reads for the idle column.
-#
-# This hook assumes that you are using the default age-file location of
-# "info/web/last-modified". If you change the value in your cgitrc then you
-# must also change it here.
-#
-# To install the hook, copy (or link) it to the file "hooks/post-receive" in
-# each of your repositories.
-#
+
+# Updates the age-file cgit reads for the idle column. The path below is the
+# default age-file, so a cgitrc that changes the setting needs the same change
+# here. To install the hook, copy or link it to hooks/post-receive in each
+# repository.
set -eu
@@ -19,14 +14,14 @@ umask 022
agefile="$(git rev-parse --git-dir)"/info/web/last-modified
# Committer dates rather than author dates, so a push of rebased or imported
-# history still counts as recent activity. Branch tips only, since an
-# annotated tag carries no committer date of its own and would sort in as an
-# empty line.
-date="$(git for-each-ref --sort=-committerdate --count=1 --format='%(committerdate:iso8601)' refs/heads/)"
+# history still counts as recent activity. Branch tips only, since an annotated
+# tag carries no committer date of its own and would sort in as an empty line.
+date="$(git for-each-ref --sort=-committerdate --count=1 \
+ --format='%(committerdate:iso8601)' refs/heads/)"
# A repository with no branches keeps whatever cgit already had, rather than
# being handed an empty file.
-[ -n "$date" ] || exit 0
+test -n "$date" || exit 0
mkdir -p "$(dirname "$agefile")"
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