summaryrefslogtreecommitdiff
path: root/lib/gitolite3
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2021-05-26 16:56:15 +0200
committerJonas Smedegaard <dr@jones.dk>2021-05-26 16:56:15 +0200
commitf94885c5d846fe04b82ba7553e6f00989c60c439 (patch)
tree80c7d0e6e804402ded101aa6dcb5d30b864d5f3d /lib/gitolite3
parentc4f983bfbb725052f7ab24545d58f1ac92a73ece (diff)
update SETUP doc and gitolite hook
Diffstat (limited to 'lib/gitolite3')
-rwxr-xr-xlib/gitolite3/hooks/common/post-receive19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/gitolite3/hooks/common/post-receive b/lib/gitolite3/hooks/common/post-receive
index ab100d9..9c9aed7 100755
--- a/lib/gitolite3/hooks/common/post-receive
+++ b/lib/gitolite3/hooks/common/post-receive
@@ -2,12 +2,16 @@
# This gitolite3 hook exports content for web publishing.
# The following gitolite3 environment variables affect its use:
-# WEB_BRANCH tree-ish (hook silently skipped if unset)
-# WEB_BASEDIR path writable by gitolite3 (default: /var/www/gitolite3)
+# WEB_BRANCH tree-ish (hook silently skipped if unset)
+# WEB_BASEDIR path writable by gitolite3 (default: /var/www/gitolite3)
+# WEB_EXEC_INIT command executed in exported dir after initial checkout
+# WEB_EXEC command executed in exported dir after every checkout
set -eu
WEB_BRANCH=${GL_OPTION_WEB_BRANCH:-}
+WEB_EXEC=${GL_OPTION_WEB_EXEC:-}
+WEB_EXEC_INIT=${GL_OPTION_WEB_EXEC_INIT:-}
[ -n "$WEB_BRANCH" ] || exit 0
@@ -20,8 +24,19 @@ export GIT_WORK_TREE
pwd
echo "Checking out content to $GIT_WORK_TREE ..."
+init=1
+[ -e "$GIT_WORK_TREE" ] || init=
+
git checkout -f "$WEB_BRANCH"
chmod -R u=rw,go=r,a+X "$GIT_WORK_TREE"
+if [ -n "$WEB_EXEC_INIT" ] && [ -n "$init" ]; then
+ ( cd "$WEB_BASEDIR" && echo "$WEB_EXEC_INIT" | sh - )
+fi
+
+if [ -n "$WEB_EXEC" ]; then
+ ( cd "$WEB_BASEDIR" && echo "$WEB_EXEC" | sh - )
+fi
+
echo "Checkout completed succesfully!"