Last active
June 15, 2016 12:05
-
-
Save tohn/9568113 to your computer and use it in GitHub Desktop.
This git-hook will print all htm-files of the latest commit message to an irc channel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requirements | |
command -v git >/dev/null 2>&1 || { echo >&2 "I require \"git\" but it's not installed. Aborting."; exit 1; } | |
command -v ii >/dev/null 2>&1 || { echo >&2 "I require \"ii\" but it's not installed. Aborting."; exit 1; } | |
# variables - change these | |
url="http://example.org" | |
server="irc.freenode.net" | |
port="8000" | |
channel="#test_channel" | |
nickname="test_bot_42" | |
root="$HOME/irc" | |
# create $root | |
if [[ ! -d "$root" ]] ; then | |
mkdir -p "$root" | |
fi | |
# connect to $server (install ii first) | |
ii -i "$root" -s "$server" -p "$port" -n "$nickname" & | |
# sleep 3 seconds so ii can connect | |
sleep 3 | |
# print all *.htm-files of the latest commit to the $channel | |
git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD \ | |
| grep ".htm" | while read line ; do | |
echo "/PRIVMSG $channel :$url/$line" > "$root/$server/in" | |
done | |
# wait 1 second | |
sleep 1 | |
# quit | |
echo "/QUIT :EOL" > "$root/$server/in" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment