]> jfr.im git - hooks.git/commitdiff
init
authorgit <redacted>
Wed, 24 Jul 2024 09:04:54 +0000 (03:04 -0600)
committergit <redacted>
Wed, 24 Jul 2024 09:04:54 +0000 (03:04 -0600)
main/post-update [new file with mode: 0755]
main/update [new file with mode: 0755]
master/post-update [new file with mode: 0755]
master/update [new file with mode: 0755]

diff --git a/main/post-update b/main/post-update
new file mode 100755 (executable)
index 0000000..25b3aca
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if git show main:README.md >/dev/null 2>&1; then
+       git show main:README.md | cmark-gfm >README.html
+else
+       if git show main:README.html >/dev/null 2>&1; then
+               git show main:README.html >README.html
+       else
+               rm -f README.html
+       fi
+fi
+exec git update-server-info
diff --git a/main/update b/main/update
new file mode 100755 (executable)
index 0000000..1cccba1
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+reponame="$(basename "$(readlink -f .)")"
+
+FORMAT="%C(auto)%h by %an (%ah: %s) sig: %G? %GS 0x%GK https://jfr.im/git/$reponame/commitdiff/%h"
+H2I="https://h2i:ef199c443ca3f1f49709dbe79c3758273658fb7cfbb2ff88ab97ef9aedd6bb30@chat.2948.ca/h2i/null"
+
+ref="$1"
+old="$2"
+new="$3"
+
+set -x
+if [ "$old" = "0000000000000000000000000000000000000000" ]; then # new branch
+       commits="created with $(git describe --always "$new")"
+elif [ "$new" = "0000000000000000000000000000000000000000" ]; then # deleted branch
+       commits="deleted from $(git describe --always "$old")"
+elif [ "$old" = "$(git merge-base "$old" "$new")" ]; then # fast-forward update
+       commits="updated from $(git describe --always "$old") -> $(git describe --always "$new")"
+elif [ "$new" = "$(git merge-base "$old" "$new")" ]; then # rollback
+       commits="!! rolled back to $(git describe --always "$new") erasing history through $(git describe --always "$old")"
+else # commit --amend, rebase, or similar
+       commits="!! rewrote history from $(git describe --always "$(git merge-base "$old" "$new")") -> $(git describe --always "$new") erasing history through $(git describe --always "$old")"
+fi
+set +x
+
+curl -sS -d "[$reponame] $ref $commits" "$H2I" >/dev/null
+
+if [ "$old" = "0000000000000000000000000000000000000000" ]; then
+       git show --no-show-signature --no-patch --pretty="tformat:$FORMAT" "$new"
+else
+       git log --no-show-signature --pretty="tformat:$FORMAT" "$old".."$new"
+fi | while read line; do
+               curl -sS -d "$line" "$H2I" >/dev/null
+done
diff --git a/master/post-update b/master/post-update
new file mode 100755 (executable)
index 0000000..6dce73a
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if git show master:README.md >/dev/null 2>&1; then
+       git show master:README.md | cmark-gfm >README.html
+else
+       if git show master:README.html >/dev/null 2>&1; then
+               git show master:README.html >README.html
+       else
+               rm -f README.html
+       fi
+fi
+exec git update-server-info
diff --git a/master/update b/master/update
new file mode 100755 (executable)
index 0000000..1cccba1
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+reponame="$(basename "$(readlink -f .)")"
+
+FORMAT="%C(auto)%h by %an (%ah: %s) sig: %G? %GS 0x%GK https://jfr.im/git/$reponame/commitdiff/%h"
+H2I="https://h2i:ef199c443ca3f1f49709dbe79c3758273658fb7cfbb2ff88ab97ef9aedd6bb30@chat.2948.ca/h2i/null"
+
+ref="$1"
+old="$2"
+new="$3"
+
+set -x
+if [ "$old" = "0000000000000000000000000000000000000000" ]; then # new branch
+       commits="created with $(git describe --always "$new")"
+elif [ "$new" = "0000000000000000000000000000000000000000" ]; then # deleted branch
+       commits="deleted from $(git describe --always "$old")"
+elif [ "$old" = "$(git merge-base "$old" "$new")" ]; then # fast-forward update
+       commits="updated from $(git describe --always "$old") -> $(git describe --always "$new")"
+elif [ "$new" = "$(git merge-base "$old" "$new")" ]; then # rollback
+       commits="!! rolled back to $(git describe --always "$new") erasing history through $(git describe --always "$old")"
+else # commit --amend, rebase, or similar
+       commits="!! rewrote history from $(git describe --always "$(git merge-base "$old" "$new")") -> $(git describe --always "$new") erasing history through $(git describe --always "$old")"
+fi
+set +x
+
+curl -sS -d "[$reponame] $ref $commits" "$H2I" >/dev/null
+
+if [ "$old" = "0000000000000000000000000000000000000000" ]; then
+       git show --no-show-signature --no-patch --pretty="tformat:$FORMAT" "$new"
+else
+       git log --no-show-signature --pretty="tformat:$FORMAT" "$old".."$new"
+fi | while read line; do
+               curl -sS -d "$line" "$H2I" >/dev/null
+done