These changes remove all need to modify the ciabot scripts for installation.
Instead, per-project configuration can be dome via variables in a [ciabot]
section of the config file.
Also, correct for the new server address.
Signed-off-by: Eric S. Raymond e...@thyrsus.com
---
contrib/ciabot/ciabot.py | 161 +-
contrib/ciabot/ciabot.sh | 117 +++--
2 files changed, 158 insertions(+), 120 deletions(-)
diff --git a/contrib/ciabot/ciabot.py b/contrib/ciabot/ciabot.py
index 9775dff..8ce04eb 100755
--- a/contrib/ciabot/ciabot.py
+++ b/contrib/ciabot/ciabot.py
@@ -11,43 +11,41 @@
#
# This script is meant to be run either in a post-commit hook or in an
# update hook. If there's nothing unusual about your hosting setup,
-# you can specify the project name with a -p option and avoid having
-# to modify this script. Try it with -n to see the notification mail
-# dumped to stdout and verify that it looks sane. With -V it dumps its
-# version and exits.
+# you can specify the project name and repo with config variables and
+# avoid having to modify this script. Try it with -n to see the
+# notification mail dumped to stdout and verify that it looks
+# sane. With -V it dumps its version and exits.
#
-# In post-commit, run it without arguments (other than possibly a -p
-# option). It will query for current HEAD and the latest commit ID to
-# get the information it needs.
+# In post-commit, run it without arguments. It will query for
+# current HEAD and the latest commit ID to get the information it
+# needs.
#
# In update, call it with a refname followed by a list of commits:
-# You want to reverse the order git rev-list emits becxause it lists
+# You want to reverse the order git rev-list emits because it lists
# from most recent to oldest.
#
# /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
#
-# Note: this script uses mail, not XML-RPC, in order to avoid stalling
-# until timeout when the CIA XML-RPC server is down.
+# Configuration variables affecting this script:
+# ciabot.project = name of the project (required)
+# ciabot.repo = name of the project repo for gitweb/cgit purposes
+# ciabot.xmlrpc = if true (default), ship notifications via XML-RPC
+# ciabot.revformat = format in which the revision is shown
#
-
-#
-# The project as known to CIA. You will either want to change this
-# or invoke the script with a -p option to set it.
+# The ciabot.repo value defaults to ciabot.project lowercased.
#
-project=None
-
+# The revformat variable may have the following values
+# raw - full hex ID of commit
+# short - first 12 chars of hex ID
+# describe = - describe relative to last tag, falling back to short
+# The default is 'describe'.
#
-# You may not need to change these:
+# Note: the CIA project now says only XML-RPC is reliable, so
+# we default to that.
#
-import os, sys, commands, socket, urllib
-
-# Name of the repository.
-# You can hardwire this to make the script faster.
-repo = os.path.basename(os.getcwd())
-# Fully-qualified domain name of this host.
-# You can hardwire this to make the script faster.
-host = socket.getfqdn()
+import os, sys, commands, socket, urllib
+from xml.sax.saxutils import escape
# 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
@@ -72,7 +70,7 @@ xml = '''\
message
generator
nameCIA Python client for Git/name
-version%(gitver)s/version
+version%(version)s/version
url%(generator)s/url
/generator
source
@@ -98,19 +96,18 @@ xml = '''\
# No user-serviceable parts below this line:
#
-# Addresses for the e-mail. The from address is a dummy, since CIA
-# will never reply to this mail.
-fromaddr = CIABOT-NOREPLY@ + host
-toaddr = c...@cia.navi.cx
+# Where to ship e-mail notifications.
+toaddr = c...@cia.vc
# Identify the generator script.
# Should only change when the script itself gets a new home and maintainer.
-generator=http://www.catb.org/~esr/ciabot.py;
+generator = http://www.catb.org/~esr/ciabot.py;
+version = 3.5
def do(command):
return commands.getstatusoutput(command)[1]
-def report(refname, merged):
+def report(refname, merged, xmlrpc=True):
Generate a commit notification to be reported to CIA
# Try to tinyfy a reference to a web view for this commit.
@@ -121,32 +118,27 @@ def report(refname, merged):
branch = os.path.basename(refname)
-# Compute a shortnane for the revision
-rev = do(git describe '+ merged +' 2/dev/null) or merged[:12]
-
-# Extract the neta-information for the commit
-rawcommit = do(git cat-file commit + merged)
+# Compute a description for the revision
+if revformat == 'raw':
+rev = merged
+elif revformat == 'short':
+rev = ''
+else: # revformat == 'describe'
+rev = do(git describe %s 2/dev/null % merged)
+if not rev:
+rev =