diff options
| -rwxr-xr-x | misc/git-post-commit.py | 14 | ||||
| -rwxr-xr-x | misc/post-receive | 11 |
2 files changed, 17 insertions, 8 deletions
diff --git a/misc/git-post-commit.py b/misc/git-post-commit.py index 775fe3b..07eeb60 100755 --- a/misc/git-post-commit.py +++ b/misc/git-post-commit.py @@ -1,10 +1,13 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ -Simple script to send a message to an IRC channel +Simple script to send messages to an IRC channel in Fire and Forget mode (non persistent connection) -Usage: git-post-commit <server[:port]> <nickname> <channel> <message> +Usage: git-post-commit <server[:port]> <nickname> <channel> + +Read lines one by one on the standard input and print them in +in the channel """ import irclib @@ -19,15 +22,16 @@ class IRCFire(irclib.SimpleIRCClient): connection.join(self.target) def on_join(self, connection, event): - self.connection.privmsg(self.target, sys.argv[4]) + for line in sys.stdin: + self.connection.privmsg(self.target, line) self.connection.quit("Commit sent") def on_disconnect(self, connection, event): sys.exit(0) def main(): - if len(sys.argv) != 5: - print "Usage: " + sys.argv[0] + " <server[:port]> <nickname> <channel> <message>" + if len(sys.argv) != 4: + print "Usage: " + sys.argv[0] + " <server[:port]> <nickname> <channel>" sys.exit(1) s = sys.argv[1].split(":", 1) diff --git a/misc/post-receive b/misc/post-receive index 09ccf95..b44916a 100755 --- a/misc/post-receive +++ b/misc/post-receive @@ -5,6 +5,11 @@ # irc notification # change the path of the python script -read oldrev newrev refname -a=`git log --format=format:"%an | %s" $oldrev..$newrev` -python git-post-commit.py "irc.freenode.net" "AliasCommit" "#alias" "$a" +{ + while read oldrev newrev refname + do + a=`git log --format=format:"%an | %s" $oldrev..$newrev` + printf "$a\n" + done +} | python git-post-commit.py "irc.freenode.net" "AliasCommit" "#alias" + |
