[Frugalware-darcs] git-hooks: git-hooks: converted from darcs-hooks

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=20070623170805-e2957-71dd38721a9cf77c7b983197af6b7a1e38f967d4.gz;

[git-hooks: converted from darcs-hooks
VMiklos <vmiklos at frugalware.org>**20070623170805] {
move ./darcs-hooks.py ./git-hooks.py
hunk ./Makefile 1
-# Makefile for darcs-hooks
+# Makefile for git-hooks
hunk ./Makefile 24
-sysconfdir = /etc/darcs-hooks
-shareddir = /usr/share/darcs-hooks
+sysconfdir = /etc/git-hooks
+shareddir = /usr/share/git-hooks
hunk ./Makefile 32
-	$(INSTALL) darcs-hooks.py $(DESTDIR)$(bindir)/darcs-hooks
+	$(INSTALL) git-hooks.py $(DESTDIR)$(bindir)/git-hooks
hunk ./Makefile 45
-dist:
-	darcs changes >_darcs/pristine/Changelog
-	darcs dist -d darcs-hooks-$(VERSION)
-	gpg --comment "See http://ftp.frugalware.org/pub/README.GPG for info" \
-		-ba -u 20F55619 darcs-hooks-$(VERSION).tar.gz
-	mv darcs-hooks-$(VERSION).tar.gz{,.asc} ../
-	rm _darcs/pristine/Changelog
-
-release:
-	darcs tag --checkpoint $(VERSION)
-	$(MAKE) dist
-
hunk ./config.py 4
-	enabled_plugins = ['cia', 'sendmail']
+	#enabled_plugins = ['cia', 'sendmail']
+	enabled_plugins = ['sendmail']
hunk ./git-hooks.py 2
-# -*- coding: iso-8859-2 -*-
hunk ./git-hooks.py 3
-import os, sys, gzip, time, re, xmlrpclib
-from xml.dom import minidom
-from xml.sax import saxutils
+import os, sys
hunk ./git-hooks.py 6
-	def __init__(self, dir, latestfile, callback):
-		self.dir = dir
-		self.latestfile = latestfile
-		self.callback = callback
+	def __init__(self, callback):
hunk ./git-hooks.py 8
-		try:
-			os.stat(dir)
-		except OSError:
-			os.makedirs(dir)
+		# currently we don't care about !master branches
+		old = None
+		for i in sys.stdin.readlines():
+			(old, new, ref) = i.split(' ')
+			if ref == "refs/heads/master":
+				break
+		if not old:
+			return
hunk ./git-hooks.py 17
-		try:
-			sock = open(os.path.join(self.dir, self.latestfile), "r")
-		except IOError:
-			sock = None
-
-		if not sock:
-			xmldoc = self.getxml("darcs chan --last 1 --xml-output")
-
-			hash = xmldoc.getElementsByTagName('patch')[0].attributes['hash'].firstChild.toxml()
-			self.puthash(hash)
-		else:
-			oldhash = sock.read().strip()
-			sock.close()
-
-			xmldoc = self.getxml('DARCS_DONT_ESCAPE_ISPRINT=1 darcs chan --from-match "hash %s" --xml-output' % oldhash)
-
-			counter = 0
-			for i in xmldoc.getElementsByTagName('patch'):
-				if counter >= len(xmldoc.getElementsByTagName('patch'))-1:
-					break
-				self.callback(i)
-				counter += 1
-
-			hash = xmldoc.getElementsByTagName('patch')[0].attributes['hash'].firstChild.toxml()
-			self.puthash(hash)
-
-	def getxml(self, cmd):
-		sock = os.popen(cmd)
-		xmldata = "".join(sock.readlines())
+		sock = os.popen("git rev-list %s..%s" % (old, new))
+		hashes = sock.readlines()
hunk ./git-hooks.py 20
-		xmldoc = minidom.parseString(self.unaccent(xmldata))
-		return xmldoc
+		hashes.reverse()
hunk ./git-hooks.py 22
-	def unaccent(self, 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 puthash(self, hash):
-		sock = open(os.path.join(self.dir, self.latestfile), "w")
-		sock.write("%s\n" % hash)
-		sock.close()
+		for i in hashes:
+			callback(i.strip())
hunk ./git-hooks.py 26
-	sys.path.append("/etc/darcs-hooks")
-	sys.path.append("/usr/share/darcs-hooks")
+	sys.path.append("/etc/git-hooks")
+	sys.path.append("/usr/share/git-hooks")
hunk ./git-hooks.py 38
-		try:
-			hook = Hook(config.config.dir, config.config.latestfile, plugin.callback)
-		except Exception, s:
-			print "Error, probably connect to CIA timed out."
+		#try:
+		hook = Hook(plugin.callback)
+		#except Exception, s:
+		#	print "Error, probably connect to CIA timed out."
}


More information about the Frugalware-darcs mailing list