[projects/git-slug: 70/170] Hook to send notifications to distfiles
glen
glen at pld-linux.org
Mon Sep 21 21:44:42 CEST 2015
commit e7f2e0881c0ff3a469a1f5048e16490364777441
Author: Kacper Kornet <draenog at pld-linux.org>
Date: Wed Dec 14 19:09:49 2011 +0000
Hook to send notifications to distfiles
post-receive.python.d/distfiles.py | 39 ++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
---
diff --git a/post-receive.python.d/distfiles.py b/post-receive.python.d/distfiles.py
new file mode 100644
index 0000000..4281e6f
--- /dev/null
+++ b/post-receive.python.d/distfiles.py
@@ -0,0 +1,39 @@
+import os
+import subprocess
+from git_slug.gitconst import EMPTYSHA1
+
+DISTFILES_EMAIL = None
+MAILFROMHOST = 'pld-linux.org'
+MAILCOMMAND = '/usr/sbin/sendmail -t'.split()
+
+def distfiles_notification(login, package, branch):
+ if DISTFILES_EMAIL is None:
+ return
+ mailprocess = subprocess.Popen(MAILCOMMAND, stdin=subprocess.PIPE)
+ mailprocess.stdin.write(
+"""To: {distfiles_email}
+From: {login} <{login}@{MAILFROMHOST}>
+Subject: cvs to df notify
+X-distfiles-request: yes
+X-Login: {login}
+X-Package: {package}
+X-Branch: {branch}
+X-Flags: git-notify
+""".format(distfiles_email=DISTFILES_EMAIL,
+ login = login,
+ MAILFROMHOST = MAILFROMHOST,
+ package = package,
+ branch = branch).encode('utf-8')
+ )
+ mailprocess.communicate()
+
+def run(data):
+ gitrepo = os.environ.get('GL_REPO')
+ if gitrepo.startswith('packages/'):
+ gitrepo = gitrepo[len('packages/'):]
+ else:
+ return
+ for line in data:
+ (sha1old, sha1, ref) = line.split()
+ if ref.startswith('refs/heads/') and sha1old != EMPTYSHA1:
+ distfiles_notification(os.getenv('GL_USER'), gitrepo, ref)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5
More information about the pld-cvs-commit
mailing list