aboutsummaryrefslogtreecommitdiff
path: root/git-hooks/post-receive
diff options
context:
space:
mode:
authorTrey Bastian <hello@treybastian.com>2026-04-08 14:36:22 +0100
committerTrey Bastian <hello@treybastian.com>2026-04-08 14:36:22 +0100
commit97c6c6b7823d9d713f836f967fd10cc3facc36ac (patch)
tree55b660d91298ed39e72dcfec050d3a3c879618c3 /git-hooks/post-receive
parent4d82c0a3f2fbf2fdaf379d087a66421a9053c1b5 (diff)
updated scripts to slightly new workflow
Diffstat (limited to 'git-hooks/post-receive')
-rwxr-xr-xgit-hooks/post-receive31
1 files changed, 18 insertions, 13 deletions
diff --git a/git-hooks/post-receive b/git-hooks/post-receive
index 3f47457..a628d02 100755
--- a/git-hooks/post-receive
+++ b/git-hooks/post-receive
@@ -6,26 +6,31 @@
#
# USAGE:
# 1) set core.hooksPath to point to where this file is located
-# ex `sudo git --config --system core.hooksPath /home/git/scripts/git-hooks`
+# ex `sudo git config --system core.hooksPath /home/git/scripts/git-hooks`
# 2) create a public.conf file in the repo of your choice with the path to your remote
# 3) push as normal and everything should mirror
REPO_PATH=$(pwd)
PUBLIC_FILE="$REPO_PATH/public.conf"
-LOGFILE="/home/git/public-sync.log" #log our syncing isssues
+LOGFILE="/home/git/public-sync.log" # log our syncing isssues
-if [ ! -f "$KNOT_FILE" ]; then
- echo "[$(date)] $REPO_PATH: public.conf not found, skipping" >> "$LOGFILE"
- exit 0
-fi
-REPO_URL=$(cat "$KNOT_FILE" | tr -d '\n' | xargs)
-if [ -z "$REPO_URL" ]; then
- echo "[$(date)] $REPO_PATH: misconfigured public.conf, skipping" >> "$LOGFILE"
- exit 0
+if [ -f "$PUBLIC_FILE" ]; then
+ REPO_URL=$(cat "$PUBLIC_FILE" | tr -d '\n' | xargs)
+ if [ -z "$REPO_URL" ]; then
+ echo "[$(date)] $REPO_PATH: misconfigured public.conf, skipping" >> "$LOGFILE"
+ else
+ OUTPUT=$(git push --mirror "$REPO_URL" 2>&1)
+ if [ $? -ne 0 ]; then
+ echo "[$(date)] MIRROR FAILED $REPO_PATH -> $REPO_URL" >> "$LOGFILE"
+ echo "$OUTPUT" >> "$LOGFILE"
+ fi
+ fi
fi
-echo "[$(date)] BEGIN PUSH $REPO_PATH" >> "$LOGFILE"
-git push --mirror "$REPO_URL" >> "$LOGFILE" 2>&1
-echo "[$(date)] END PUSH $REPO_PATH" >> "$LOGFILE"
+# run repo specific post-recieve hook if it existst
+REPO_HOOK="$(git rev-parse --git-dir)/hooks/post-receive"
+if [ -x "$REPO_HOOK" ]; then
+ "$REPO_HOOK" "$@"
+fi
# vim: filetype=bash