[Frugalware-darcs] git-hooks: sendmail: converted to git

VMiklos vmiklos at frugalware.org
Mon Jun 25 13:04:07 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=git-hooks;a=darcs_commitdiff;h=20070623170831-e2957-fa0560c8a583b264877fff9f0abb4271986cfcbc.gz;

[sendmail: converted to git
VMiklos <vmiklos at frugalware.org>**20070623170831] {
hunk ./sendmail/config.py 6
-	dir = os.path.join("_darcs", "third_party", "email")
-	latestfile = "latest"
-	dest = "frugalware-darcs at frugalware.org"
+	dest = "frugalware-git at frugalware.org"
hunk ./sendmail/config.py 8
-	darcsweb_url = "http://darcs.frugalware.org/darcsweb/darcsweb.cgi"
+	gitweb_url = "http://git.frugalware.org"
hunk ./sendmail/sendmail.py 2
-# -*- coding: iso-8859-2 -*-
hunk ./sendmail/sendmail.py 3
-import os, gzip, smtplib
-from xml.dom import minidom
-from xml.sax import saxutils
+import os, smtplib
hunk ./sendmail/sendmail.py 6
-def getpatch(hash):
-	sock = gzip.GzipFile(os.path.join("_darcs", "patches", "%s") % hash)
-	data = unaccent("".join(sock.readlines()))
-	sock.close()
-	return data
-
-def unaccent(s):
-	ret = []
-	fro = "AEIOOOUUUaeiooouuu"
-	to = "AEIOOOUUUaeiooouuu"
-	for i in s:
-		if i in fro:
-			ret.append(to[fro.index(i)])
-		else:
-			ret.append(i)
-	return "".join(ret)
-
-def callback(patch):
+def callback(hash):
hunk ./sendmail/sendmail.py 9
-	repo = os.path.split(os.getcwd())[-1]
-	patchname = patch.getElementsByTagName("name")[0].firstChild.toxml()
-	hash = saxutils.unescape(patch.attributes['hash'].firstChild.toxml())
-
-	fro = saxutils.unescape(patch.attributes['author'].firstChild.toxml())
+	repo = os.getcwd().split("/")[-1]
+	if repo == ".git":
+		repo = os.getcwd().split("/")[-2]
+	sock = os.popen('git log -1 --pretty=format:"%s" ' + hash)
+	name = sock.read()
+	sock.close()
+	sock = os.popen('git log -1 --pretty=format:"%an <%ae>" ' + hash)
+	fro = sock.read()
+	sock.close()
hunk ./sendmail/sendmail.py 19
-	subject = "%s: %s" % (repo, patchname)
+	subject = "%s: %s" % (repo, name)
hunk ./sendmail/sendmail.py 22
-	if config.darcsweb_url:
-		msg.append("Darcsweb-Url: %s?r=%s;a=darcs_commitdiff;h=%s;\n" % (config.darcsweb_url, repo, hash))
-	msg.append(getpatch(hash))
+	if config.gitweb_url:
+		msg.append("Git-Url: %s/?p=%s;a=commitdiff;h=%s\n" % (config.gitweb_url, repo, hash))
+	sock = os.popen("git show " + hash)
+	lines = []
+	for i in sock.readlines():
+		lines.append(i.strip())
+	msg.extend(lines)
+	sock.close()
hunk ./sendmail/sendmail.py 38
-if __name__ == "__main__":
-	hook = Hook(config.dir, config.latestfile, sendpatch)
-
}


More information about the Frugalware-darcs mailing list