From b96a91bc2b8280400afb6b683b6d64b46a121264 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 9 Nov 2023 21:43:05 +0000 Subject: put hook script in here too --- README.md | 6 +++++- post-recieve.sh | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 post-recieve.sh 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 -- cgit v1.2.3