Created
May 8, 2010 01:45
-
-
Save panquetofobia/394231 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env/python | |
""" | |
This script is executed through the post-receive hook | |
after a git repo receives data (someone git-pushed) | |
and notifies subscribers of the event via growl. | |
depends on the netgrowl module http://the.taoofmac.com/space/projects/netgrowl | |
""" | |
import sys | |
from netgrowl import * | |
subscribers = ( | |
'192.168.0.13', | |
) | |
def notify(ip, title, description): | |
addr = (ip, GROWL_UDP_PORT) | |
s = socket(AF_INET, SOCK_DGRAM) | |
p = GrowlRegistrationPacket(application="ChismeGitPush", password="PASSWORD") | |
p.addNotification("Git Push", enabled=True) | |
p.addNotification("Avisos Git opcionales") | |
s.sendto(p.payload(), addr) | |
p = GrowlNotificationPacket( | |
application="ChismeGitPush", | |
notification="Git Push", | |
title=title, | |
description=description, | |
priority=1, | |
sticky=True, | |
password="PASSWORD") | |
s.sendto(p.payload(),addr) | |
print s | |
print ip, title, description | |
s.close() | |
def main(): | |
repo = sys.argv[1].split('/')[-1] | |
log = " ".join(sys.argv[2:]) | |
author, hash, message = log.split('|') | |
title = '%s push by %s' % (repo, author.split()[0]) | |
description = '%s: %s' % (hash, message) | |
for subscriber in subscribers: | |
notify(subscriber, title, description) | |
if __name__ == '__main__': | |
main() |
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/sh | |
python gitpushnotifygrowl.py $(pwd) $(git log --pretty=format:"%an|%h|%s" -n 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment