From 4d82c0a3f2fbf2fdaf379d087a66421a9053c1b5 Mon Sep 17 00:00:00 2001 From: Trey Bastian Date: Tue, 7 Apr 2026 13:59:57 +0100 Subject: updated scripts to use new public and allow for repo specific hooks to still exist --- git-hooks/hook-runner | 13 +++++++++++++ git-hooks/post-receive | 12 ++++++------ git-hooks/post-update | 1 + git-hooks/pre-recieve | 1 + git-hooks/update | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) create mode 100755 git-hooks/hook-runner create mode 120000 git-hooks/post-update create mode 120000 git-hooks/pre-recieve create mode 120000 git-hooks/update (limited to 'git-hooks') diff --git a/git-hooks/hook-runner b/git-hooks/hook-runner new file mode 100755 index 0000000..a13e00c --- /dev/null +++ b/git-hooks/hook-runner @@ -0,0 +1,13 @@ +#!/bin/bash + +# when core.hooksPath is set in git all hooks become global this script ensures +# repo specific hooks will still be run +# symlink this file to all missing hook scripts + +HOOK_NAME=$(basename "$0") +REPO_HOOK="$(git rev-parse --git-dir)/hooks/$HOOK_NAME" + +if [ -x "$REPO_HOOK"]; then + "$REPO_HOOK" +fi +# vim: filetype=bash diff --git a/git-hooks/post-receive b/git-hooks/post-receive index 21c3503..3f47457 100755 --- a/git-hooks/post-receive +++ b/git-hooks/post-receive @@ -1,26 +1,26 @@ #!/bin/bash # this post-receive hook runs globally on my local git machine -# if the knot.conf file exists it reads it to get the remote repo and mirror pushes +# if the public.conf file exists it reads it to get the remote repo and mirror pushes # if the file doesn't exist, it doesn't mirror the repo AKA it's private and it stays on my network # # 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` -# 2) create a knot.conf file in the repo of your choice with the path to your remote +# 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) -KNOT_FILE="$REPO_PATH/knot.conf" -LOGFILE="/home/git/knot-sync.log" #log our syncing isssues +PUBLIC_FILE="$REPO_PATH/public.conf" +LOGFILE="/home/git/public-sync.log" #log our syncing isssues if [ ! -f "$KNOT_FILE" ]; then - echo "[$(date)] $REPO_PATH: knot.conf not found, skipping" >> "$LOGFILE" + 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 knot.conf, skipping" >> "$LOGFILE" + echo "[$(date)] $REPO_PATH: misconfigured public.conf, skipping" >> "$LOGFILE" exit 0 fi diff --git a/git-hooks/post-update b/git-hooks/post-update new file mode 120000 index 0000000..fa59448 --- /dev/null +++ b/git-hooks/post-update @@ -0,0 +1 @@ +hook-runner \ No newline at end of file diff --git a/git-hooks/pre-recieve b/git-hooks/pre-recieve new file mode 120000 index 0000000..fa59448 --- /dev/null +++ b/git-hooks/pre-recieve @@ -0,0 +1 @@ +hook-runner \ No newline at end of file diff --git a/git-hooks/update b/git-hooks/update new file mode 120000 index 0000000..fa59448 --- /dev/null +++ b/git-hooks/update @@ -0,0 +1 @@ +hook-runner \ No newline at end of file -- cgit v1.2.3