Version control the post-receive githook.

This commit is contained in:
Joris Vink 2023-01-05 09:14:57 +01:00
parent 4ecd6d5603
commit 7632705c64
1 changed files with 24 additions and 0 deletions

24
misc/hooks/post-receive Normal file
View File

@ -0,0 +1,24 @@
#!/usr/local/bin/bash
set -x
set -e
URL=discord-hook
while read oldrev newrev ref; do
if [[ $ref =~ .*/master$ ]]; then
logmsg=""
commits=$(git rev-list ${oldrev}..${newrev})
for commit in $commits; do
log=$(git log -1 --pretty=format:'[%h](https://github.com/jorisvink/kore/commit/%H) %cn: %s' $commit)
logmsg="$logmsg $log\\n"
done
curl -i \
-H "Accept: application/json" \
-H "Content-type: application/json" \
-X POST \
-d "{\"content\": \"${logmsg}\"}" \
$URL
fi
done