Skip to content
Snippets Groups Projects
Commit 8e63ce73 authored by Eric S. Raymond's avatar Eric S. Raymond
Browse files

More cleanup and extension of config-variable processing.

parent 9c88bded
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -69,7 +69,7 @@ specified, defaults to a lowercased copy of the project name.</para>
<term>channels</term>
<listitem>
<para>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.</para>
</listitem>
......@@ -100,6 +100,18 @@ work if you have a typical gitweb/cgit setup.</para>
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.</para>
<para>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
<application>irkerhook.py</application> is running; the latter is
expanded to the value of the "repo" variable.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>tinyifier</term>
<listitem>
<para>URL template pointing to a service for compressing URLs so they
will take up less space in the notification line.</para>
</listitem>
</varlistentry>
</variablelist>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment