aboutsummaryrefslogtreecommitdiffstats
path: root/misc/git-post-commit.py
diff options
context:
space:
mode:
authorZaran <zaran.krleza@gmail.com>2011-09-21 01:34:23 +0200
committerZaran <zaran.krleza@gmail.com>2011-09-21 01:34:23 +0200
commitc607a0177e6950e098d0f655dc4b8d6008d50710 (patch)
tree6926a1a3c770c5384293538abaa26b971ee5ad07 /misc/git-post-commit.py
parent4264d6c6360c234d789df2ea513bb83022f41ab3 (diff)
downloadalias-c607a0177e6950e098d0f655dc4b8d6008d50710.tar.gz
Improve irc notification to support multiple commits.
post-recieve hooks print all the commit lines to standard output which is piped to git-post-commit.py. git-post-commit.py now reads on standard input, one line at a time and prints in the channel.
Diffstat (limited to 'misc/git-post-commit.py')
-rwxr-xr-xmisc/git-post-commit.py14
1 files changed, 9 insertions, 5 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)