From 0e599e6a61b1096aa88a5e83e0672f34fcdd54d5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 28 Mar 2010 09:20:53 -0400 Subject: Document the ciabot.py formatting options better. --- repo/hooks/ciabot.py | 73 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 31 deletions(-) (limited to 'repo') diff --git a/repo/hooks/ciabot.py b/repo/hooks/ciabot.py index 73336fd3..4e20caea 100755 --- a/repo/hooks/ciabot.py +++ b/repo/hooks/ciabot.py @@ -43,16 +43,49 @@ host = socket.getfqdn() # Changeset URL prefix for your repo: when the commit ID is appended # to this, it should point at a CGI that will display the commit -# through gitweb or something similar. The default will probably +# through gitweb or something similar. The defaults will probably # work if you have a typical gitweb/cgit setup. # -#urlprefix="http://%(host)s/cgi-bin/gitweb.cgi?p=%(repo)s;a=commit;h="%locals() -urlprefix="http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id="%locals() +#urlprefix="http://%(host)s/cgi-bin/gitweb.cgi?p=%(repo)s;a=commit;h=" +urlprefix="http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id=" # The service used to turn your gitwebbish URL into a tinyurl so it # will take up less space on the IRC notification line. tinyifier = "http://tinyurl.com/api-create.php?url=" +# The template used to generate the XML messages to CIA. You can make +# visible changes to the IRC-bot notfication lines by hacking this. +# The default will produce a notfication line that looks like this: +# +# ${project}: ${author} ${repo}:${branch} * ${rev} ${files}: ${logmsg} ${url} +# +# By omitting $files you can collapse the files part to a single slash. +xml = '''\ + + + CIA Shell client for Git + %(gitver)s + %(generator)s + + + %(project)s + %(repo)s:%(branch)s + + %(ts)s + + + %(author)s + %(rev)s + + %(files)s + + %(logmsg)s %(url)s + %(url)s + + + +''' + # # No user-serviceable parts below this line: # @@ -79,6 +112,8 @@ os.environ["PATH"] += ":/usr/sbin/:" + do("git --exec-path") # Option flags mailit = True +urlprefix = urlprefix % globals() + def report(refname, merged): "Report a commit notification to CIA" @@ -88,7 +123,7 @@ def report(refname, merged): except: url = urlprefix + merged - shortref = os.path.basename(refname) + branch = os.path.basename(refname) # Compute a shortnane for the revision rev = do("git describe ${merged} 2>/dev/null") or merged[:12] @@ -98,7 +133,7 @@ def report(refname, merged): files=do("git diff-tree -r --name-only '"+ merged +"' | sed -e '1d' -e 's-.*-&-'") inheader = True headers = {} - logmessage = "" + logmsg = "" for line in rawcommit.split("\n"): if inheader: if line: @@ -107,7 +142,7 @@ def report(refname, merged): else: inheader = False else: - logmessage = line + logmsg = line break (author, ts) = headers["author"].split(">") author = author.replace("<", "").split("@")[0].split()[-1] @@ -116,31 +151,7 @@ def report(refname, merged): context = locals() context.update(globals()) - out = '''\ - - - CIA Shell client for Git - %(gitver)s - %(generator)s - - - %(project)s - %(repo)s:%(shortref)s - - %(ts)s - - - %(author)s - %(rev)s - - %(files)s - - %(logmessage)s %(url)s - %(url)s - - - -''' % context + out = xml % context message = '''\ Message-ID: <%(merged)s.%(author)s@%(project)s> -- cgit v1.2.1