From 8e63ce73df056fda4eac6a4b78f1942ac4748d02 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 30 Sep 2012 11:07:41 -0400 Subject: [PATCH] More cleanup and extension of config-variable processing. --- irkerhook.py | 27 +++++++++++---------------- irkerhook.xml | 14 +++++++++++++- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/irkerhook.py b/irkerhook.py index 29e0355..6a10862 100755 --- a/irkerhook.py +++ b/irkerhook.py @@ -13,22 +13,15 @@ # # See the irkerhook manual page in the distribution for a detailed # explanation of how to configure this hook. -# -# Other configuration changes you may want to make are to: -# -# urlprefix: the current version should work for viewcvs or gitweb -# installations, but will require modification for other systems. -# -# tinyfier: If your project maintains its own url-shrinking service # The default location of the irker proxy, if the project configuration # does not override it. default_server = "localhost" IRKER_PORT = 6659 -# The default service used to turn your gitwebbish URL into a tinyurl so it +# The default service used to turn your web-view URL into a tinyurl so it # will take up less space on the IRC notification line. -tinyifier = "http://tinyurl.com/api-create.php?url=" +default_tinyifier = "http://tinyurl.com/api-create.php?url=" # Map magic urlprefix values to actual URL prefixes. urlprefixmap = { @@ -37,6 +30,9 @@ urlprefixmap = { "cgit": "http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id=", } +# By default, the channel list includes the freenode #commits list +default_channels = "irc://chat.freenode.net/%(project)s,irc://chat.freenode.net/#commits" + # # No user-serviceable parts below this line: # @@ -56,7 +52,7 @@ def urlify(extractor, commit): prefix = extractor.urlprefix % extractor.__dict__ # Try to tinyfy a reference to a web view for this commit. try: - url = open(urllib.urlretrieve(tinyifier + prefix + commit)[0]).read() + url = open(urllib.urlretrieve(extractor.tinyifier + prefix + commit)[0]).read() except: url = prefix + commit return url @@ -72,6 +68,7 @@ class GitExtractor: self.tcp = do("git config --bool --get irker.tcp") self.template = '%(project)s: %(author)s %(repo)s:%(branch)s * %(rev)s / %(files)s: %(logmsg)s %(url)s' self.urlprefix = do("git config --get irker.urlprefix") or "gitweb" + self.tinyifier = default_tinyifier # This one is git-specific self.revformat = do("git config --get irker.revformat") # The project variable defaults to the name of the repository toplevel. @@ -164,6 +161,7 @@ class SvnExtractor: self.rev = "r%s" % self.commit self.template = '%(project)s: %(author)s %(repo)s * %(rev)s / %(files)s: %(logmsg)s %(url)s' self.urlprefix = "viewcvs" + self.tinyifier = default_tinyifier load_preferences(self, os.path.join(self.repository, "irker.conf")) def svnlook(self, info): return do("svnlook %s %s --revision %s" % (shellquote(info), shellquote(self.repository), shellquote(self.commit))) @@ -188,11 +186,9 @@ if __name__ == "__main__": print "irkerhook.py: version", version sys.exit(0) - # Gather info for repo type discrimination, make globals settable + # Gather info for repo type discrimination for tok in arguments: - if tok.startswith("tinyfier="): - tinyfier = tok[9:] - elif tok.startswith("repository="): + if tok.startswith("repository="): repository = tok[11:] # Determine the repository type. Default to git unless user has pointed @@ -223,9 +219,8 @@ if __name__ == "__main__": else: setattr(extractor, key, val) - # By default, the channel list includes the freenode #commits list if not extractor.channels: - extractor.channels = "irc://chat.freenode.net/%s,irc://chat.freenode.net/#commits" % extractor.project + extractor.channels = default_channels % extractor.__dict__ # Other defaults get set here if not extractor.repo: extractor.repo = extractor.project.lower() diff --git a/irkerhook.xml b/irkerhook.xml index 759e537..9efd9ee 100644 --- a/irkerhook.xml +++ b/irkerhook.xml @@ -69,7 +69,7 @@ specified, defaults to a lowercased copy of the project name. channels An IRC channel URL, or comma-separated list of same, identifying -channels to which notofications are to be sent. If not specified, the +channels to which notifications are to be sent. If not specified, the defaults channel list id the freenode #commits channel plus the freenode channel named by the project variable. @@ -100,6 +100,18 @@ work if you have a typical gitweb/cgit setup. field in commit notifications will be suppressed. Other magic values are "cgit", "gitweb", and "viewcvs", which expand to URL templates that will usually work with those systems. + +The magic cookies "%(host)s" and %(repo)s" may occur in this +URL. The former is expanded to the FQDN of the host on which +irkerhook.py is running; the latter is +expanded to the value of the "repo" variable. + + + +tinyifier + +URL template pointing to a service for compressing URLs so they +will take up less space in the notification line. -- 2.26.2