summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar steering72532026-05-18 09:25:02 -0600
committerGravatar steering72532026-05-18 09:25:02 -0600
commita0140beadfffdb821b0236daeac4ae637a284b19 (patch)
tree23a0850134393f65a8f186ac941f73b8142f1840
parentadd user to notifications (diff)
add hooks.notify
-rwxr-xr-xpost-update6
-rwxr-xr-xupdate19
2 files changed, 21 insertions, 4 deletions
diff --git a/post-update b/post-update
index 98ed0a3..4a91eb3 100755
--- a/post-update
+++ b/post-update
@@ -3,6 +3,12 @@
default_branch="$(git rev-parse --abbrev-ref HEAD)"
default_branch_path="$(git rev-parse --symbolic-full-name HEAD)"
+if [ -n "$GIT_DIR" ]; then
+ cd "$GIT_DIR"
+elif [ -d .git ]; then
+ cd .git
+fi
+
mkdir -p info/web
if git show "$default_branch":README.md >/dev/null 2>&1; then
diff --git a/update b/update
index 69b9308..330c103 100755
--- a/update
+++ b/update
@@ -11,7 +11,7 @@ reponame="$(readlink -f .)"
reponame="${reponame#/home/}"
FORMAT="%C(auto)%h by %an (%ah: %s) sig: %G? %GS 0x%GK https://cgit.space/~$reponame/commit/?id=%h"
-NC=( nc -q 0 "${to_host:-127.0.0.1}" "${to_port:-1337}" )
+NC=( nc -q 0 )
ref="$1"
old="$2"
@@ -19,6 +19,7 @@ new="$3"
allowForcePush="$(git config --type=bool hooks.allowForcePush)"
protectedRefs="$(git config --default "$default_branch_path" hooks.protectedRefs)"
+addlNotify="$(git config get --value '^([a-zA-Z0-9_.-]+|[0-9.]+|[0-9a-fA-F:.]+):[0-9]{1,5}$' hooks.notify)"
commits=""
forced=""
@@ -38,7 +39,10 @@ else # commit --amend, rebase, or similar
fi
#curl -sS -d "[$reponame] $ref $commits" "$H2I" >/dev/null
-echo "[$reponame] $ref $commits by $USER" | "${NC[@]}" >/dev/null
+echo "[$reponame] $ref $commits by $USER" | "${NC[@]}" "${to_host:-127.0.0.1}" "${to_port:-1337}" >/dev/null
+if [ -n "$addlNotify" ]; then
+ echo "[$reponame] $ref $commits by $USER" | "${NC[@]}" "${addlNotify%:*}" "${addlNotify##*:}" >/dev/null
+fi
if ((16#$old == 0)); then
git log --no-show-signature --no-patch --pretty="tformat:$FORMAT" "$new"
@@ -46,11 +50,18 @@ else
git log --no-show-signature --pretty="tformat:$FORMAT" "$old".."$new"
fi | while read line; do
: #curl -sS -d "$line" "$H2I" >/dev/null
- echo "$line" | "${NC[@]}" >/dev/null
+ echo "$line" | "${NC[@]}" "${to_host:-127.0.0.1}" "${to_port:-1337}" >/dev/null
+
+ if [ -n "$addlNotify" ]; then
+ echo "$line" | "${NC[@]}" "${addlNotify%:*}" "${addlNotify##*:}"
+ fi
done
if [[ $forced == "true" && $allowForcePush != "true" && $ref =~ $protectedRefs ]]; then
- echo "(BLOCKED PUSH, 'git config hooks.allowForcePush true' on server to allow)" | "${NC[@]}" >/dev/null
+ echo "(BLOCKED PUSH, 'git config hooks.allowForcePush true' on server to allow)" | "${NC[@]}" "${to_host:-127.0.0.1}" "${to_port:-1337}" >/dev/null
+ if [ -n "$addlNotify" ]; then
+ echo "(BLOCKED PUSH, 'git config hooks.allowForcePush true' on server to allow)" | "${NC[@]}" "${addlNotify%:*}" "${addlNotify##*:}" >/dev/null
+ fi
exit 1
fi