[kde-services-devel] r507 - in trunk/commitfilter: . rules
josef at new.kstuff.org
josef at new.kstuff.org
Sat Apr 18 18:53:07 CEST 2009
Author: josef
Date: 2009-04-18 18:53:07 +0200 (Sat, 18 Apr 2009)
New Revision: 507
Added:
trunk/commitfilter/rules/
trunk/commitfilter/rules/cia2eximfilter
trunk/commitfilter/rules/example.xml
Log:
- first import for a complex rule filter based on CIA rule scripts
Added: trunk/commitfilter/rules/cia2eximfilter
===================================================================
--- trunk/commitfilter/rules/cia2eximfilter (rev 0)
+++ trunk/commitfilter/rules/cia2eximfilter 2009-04-18 16:53:07 UTC (rev 507)
@@ -0,0 +1,107 @@
+#!/usr/bin/env ruby
+
+#load 'hpricot.rb'
+require 'hpricot'
+
+class CIA2Exim
+ def convert(doc)
+ case doc.root.name
+ when "or":
+ str = convert_or([doc.root])
+ when "and":
+ str = convert_and([doc.root])
+ else
+ str = convert_match([doc.root])
+ end
+ return str[0]
+ end
+
+ def convert_or(items)
+ if not items then return [] end
+ exitems = []
+ items.each do |item|
+ exitems += convert_or(item/"/or")
+ exitems += convert_and(item/"/and")
+ exitems += convert_not(item/"/not")
+ exitems += convert_match(item/"/match")
+ end
+ exitems_or = ""
+ exitems.each do |exitem|
+ if exitems_or != ""
+ exitems_or += " or "
+ end
+ exitems_or += "#{exitem}"
+ end
+ return [exitems_or]
+ end
+
+ def convert_and(items)
+ if not items then return [] end
+ exitems = []
+ items.each do |item|
+ ##puts "**" + item
+ exitems += convert_or(item/"/or")
+ exitems += convert_and(item/"/and")
+ exitems += convert_not(item/"/not")
+ exitems += convert_match(item/"/match")
+ end
+ exitems_and = ""
+ exitems.each do |exitem|
+ if exitems_and != ""
+ exitems_and += " and "
+ end
+ exitems_and += "#{exitem}"
+ end
+ return [exitems_and]
+ end
+
+ def convert_not(items)
+ if not items then return [] end
+ exitems = []
+ items.each do |item|
+ exitems += convert_or(item/"/or")
+ exitems += convert_and(item/"/and")
+ exitems += convert_not(item/"/not")
+ exitems += convert_match(item/"/match")
+ end
+ exitems_not = "not("
+ exitems.each do |exitem|
+ if exitems_not != "not("
+ exitems_not += " and "
+ end
+ exitems_not += "#{exitem}"
+ end
+ exitems_not += ")"
+ return [exitems_not]
+ end
+
+ def convert_match(items)
+ exitems = []
+ items.each do |item|
+ path = item.attributes["path"]
+ match = (item/"text()").to_s.strip
+ #puts "PATH", path, match.strip
+ case path
+ when "author":
+ exitems << "(author = '#{match}')"
+ when "url":
+ exitems << "(url = '#{match}')"
+ when "project":
+ exitems << "(project = '#{match}')"
+ else
+ #raise "BLARGH #{path}"
+ # ignore...
+ end
+ end
+ return exitems
+ end
+end
+
+doc = open("example.xml") do |f|
+ doc = Hpricot.XML(f)
+
+ c2e = CIA2Exim.new
+ str = c2e.convert(doc)
+ puts str
+end
+
Property changes on: trunk/commitfilter/rules/cia2eximfilter
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/commitfilter/rules/example.xml
===================================================================
--- trunk/commitfilter/rules/example.xml (rev 0)
+++ trunk/commitfilter/rules/example.xml 2009-04-18 16:53:07 UTC (rev 507)
@@ -0,0 +1,46 @@
+<or>
+
+ Show Micah's commits, but filter out a few projects where
+ there are other folks that also commit under the name "micah".
+
+ <and>
+ <match path="author"> micah </match>
+ <not><match path="project"> kde </match></not>
+ <not><match path="project"> debian-kernel </match></not>
+
+ <match path="url"> foo </match>
+ </and>
+
+ These are more people that hang out in #tacobeam.
+ Show all their commits.
+
+ <match path="author"> chipx86 </match>
+
+ We want to show Mike's commits, but he has an awfully common name,
+ so we'll explititly list the projects he's involved in. This uses
+ 'find' rather than 'match' on Mike, since some projects include his
+ email address in the author name.
+
+ <and>
+ <find path="author"> Mike </find>
+ <or>
+ <match path="project"> galago </match>
+ <match path="project"> autopackage </match>
+ </or>
+ </and>
+
+ We like Kergoth, but we got tired of his commits to KergothWOWBits.
+ Explicitly filter out that project when we accept commits from him.
+
+ <and>
+ <match path="author"> kergoth </match>
+ <not><match path="project"> KergothWOWBits </match></not>
+ </and>
+
+ These are some projects hosted on our servers.
+ Show all the commits to them.
+
+ <match path="project"> navi-misc </match>
+ <match path="project"> view </match>
+
+</or>
More information about the kde-services-devel
mailing list