aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-11-09 21:43:05 +0000
committerubq323 <ubq323@ubq323.website>2023-11-09 21:43:05 +0000
commitb96a91bc2b8280400afb6b683b6d64b46a121264 (patch)
treeae7cc96d4bacaa1607bd87f4a303c0aeaa6f9eea
parentb34e389a1c04ceac25352b0d265972449a3168a2 (diff)
put hook script in here tooHEADmaster
-rw-r--r--README.md6
-rw-r--r--post-recieve.sh12
2 files changed, 17 insertions, 1 deletions
diff --git a/README.md b/README.md
index fac448a..162a902 100644
--- a/README.md
+++ b/README.md
@@ -16,5 +16,9 @@ it should be posix-compatibile, though i've only tested it on linux with glibc.
## bugs, patches, communication, contribution, community,
email anything to me at [ubq323@ubq323.website](mailto:ubq323@ubq323.website).
-# webhooks.go
+# other files
+## post-recieve.sh
+this is the hook script i use to announce new git commits over irc, via apiobot. install it as `repo.git/hooks/post-recieve`. if you use it yourself, you'll probably want to customize it somewhat
+
+## webhooks.go
this go program runs a web server which can be used to provide a web interface to irc, by sending messages sent to it to one of apiobot's unix sockets. it currently does not support multiple channels and is also not very well designed.
diff --git a/post-recieve.sh b/post-recieve.sh
new file mode 100644
index 0000000..5bda671
--- /dev/null
+++ b/post-recieve.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+reponame=$(basename $(git rev-parse --absolute-git-dir) .git)
+while read old new ref; do
+ ccount=$(git rev-list "$new" ^"$old" | wc -l)
+ s="s"
+ [ "$ccount" -eq 1 ] && s=
+ echo "$reponame: $ref: $ccount commit$s (https://g.gh0.pw/${reponame}/)"
+ git log --format='format: %h %an - %s' "$new" ^"$old" | sed -e '$a\'
+done | while IFS= read line; do
+ echo "$line" | nc -Uu -q0 /srv/apiobot/ch/a.sock
+ echo "$line"
+done