@echo -n "LLOC: "; grep -vE '(^ *#|^ *$$)' irkerd irkerhook.py | wc -l
SOURCES = README COPYING NEWS install.txt security.txt hacking.txt \
- irkerd irkerhook.py Makefile irkerd.xml irkerhook.xml
+ irkerd irkerhook.py filter-example.py Makefile irkerd.xml irkerhook.xml
EXTRA_DIST = irker-logo.png org.catb.irkerd.plist
version:
irker history
+1.7 @
+ Optional metadata filtering with a user-specified command.
+
1.6 @ 2012-10-04
This is a stable release.
In 1.5 trying to appease pylint broke the Mercurial hook.
--- /dev/null
+#!/usr/bin/env python
+# This is a trivial example of a metadata filter.
+# All it does is change the name of the commit's author.
+# It could do other things, including modifying the
+# channels list
+#
+import sys, json
+metadata = json.loads(sys.argv[1])
+
+metadata['author'] = "The Great and Powerful Oz"
+
+print json.dumps(metadata)
+# end
support.
Laurent Bachelier <laurent@bachelier.name> fixed the Makefile so it
-wouldn't break stuff and added the external filtering option.
+wouldn't break stuff and wrote the first version of the external
+filtering option.
dak180 (name withheld by request) wrote the OS X launchd plist.
"Ship a notification for the specified commit."
metadata = extractor.commit_factory(commit)
+ # This is where we apply filtering
+ if extractor.filtercmd:
+ data = do('%s %s' % (shellquote(extractor.filtercmd),
+ shellquote(json.dumps(metadata.__dict__))))
+ try:
+ metadata.__dict__.update(json.loads(data))
+ except ValueError:
+ sys.stderr.write("irkerhook.py: could not decode JSON: %s\n" % data)
+ raise SystemExit, 1
+
# Message reduction. The assumption here is that IRC can't handle
# lines more than 510 characters long. If we exceed that length, we
# try knocking out the file list, on the theory that for notification
metadata.files = ""
privmsg = str(metadata)
- # Anti-spamming guard.
- channels = extractor.channels.split(",")
+ # Anti-spamming guard. It's deliberate that we get maxchannels not from
+ # the user-filtered metadata but from the extractor data - means repo
+ # administrators can lock in that setting.
+ channels = metadata.channels.split(",")
if extractor.maxchannels != 0:
channels = channels[:extractor.maxchannels]
</refsect2>
+<refsect2 id="filter"><title>Filtering</title>
+
+<para>It is possible to filter commits before sending them to
+<application>irkerd</application>.</para>
+
+<para>You have to specify the <option>filtercmd</option> option, which
+will be the command <application>irkerhook.py</application> will
+run. This command should accept one arguments, which is a JSON
+representation of commit and extractor metadata (including the
+channels variable). The command should emit to standard output a JSON
+representation of (possibly altered) metadata.</para>
+
+<para>Below is an example filter:</para>
+
+<programlisting>
+#!/usr/bin/env python
+# This is a trivial example of a metadata filter.
+# All it does is change the name of the commit's author.
+#
+import sys, json
+metadata = json.loads(sys.argv[1])
+
+metadata['author'] = "The Great and Powerful Oz"
+
+print json.dumps(metadata)
+# end
+</programlisting>
+
+</refsect2>
+
</refsect1>
<refsect1 id='options'><title>OPTIONS</title>