contrib: remove ciabot
Almost a year ago the CIA service irrevocably crashed. The CIA author had plans to revive the service, but the effort has since sunk without trace. Projects tend to use "irker" instead these days. Repository hook scripts for irker ship with the irker distribution. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Acked-by: Eric S. Raymond <esr@thyrsus.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Stefan Beller committed
Sep 26, 2013 at 22:33 UTC
6dab2781a1dea0c5dd52ac3bddaed08ec08e8969
4 files changed
-553
contrib/ciabot/INSTALL
deleted
-54
@@ -1,54 +0,0 @@
1
-= Installation instructions =
2
-
3
-Two scripts are included. The Python one (ciabot.py) is faster and
4
-more capable; the shell one (ciabot.sh) is a fallback in case Python
5
-gives your git hosting site indigestion. (I know of no such sites.)
6
-
7
-It is no longer necessary to modify the script in order to put it
8
-in place; in fact, this is now discouraged. It is entirely
9
-configurable with the following git config variables:
10
-
11
-ciabot.project = name of the project
12
-ciabot.repo = name of the project repo for gitweb/cgit purposes
13
-ciabot.xmlrpc = if true, ship notifications via XML-RPC
14
-ciabot.revformat = format in which the revision is shown
15
-
16
-The revformat variable may have the following values
17
-raw -> full hex ID of commit
18
-short -> first 12 chars of hex ID
19
-describe -> describe relative to last tag, falling back to short
20
-
21
-ciabot.project defaults to the directory name of the repository toplevel.
22
-ciabot.repo defaults to ciabot.project lowercased.
23
-ciabot.xmlrpc defaults to True
24
-ciabot.revformat defaults to 'describe'.
25
-
26
-This means that in the normal case you need not do any configuration at all,
27
-however setting ciabot.project will allow the hook to run slightly faster.
28
-
29
-Once you've set these variables, try your script with -n to see the
30
-notification message dumped to stdout and verify that it looks sane.
31
-
32
-To live-test these scripts, your project needs to have been registered with
33
-the CIA site. Here are the steps:
34
-
35
-1. Open an IRC window on irc://freenode/commits or your registered
36
- project IRC channel.
37
-
38
-2. Run ciabot.py and/or ciabot.sh from any directory under git
39
- control.
40
-
41
-You should see a notification on the channel for your most recent commit.
42
-
43
-After verifying correct function, install one of these scripts either
44
-in a post-commit hook or in an update hook.
45
-
46
-In post-commit, run it without arguments. It will query for
47
-current HEAD and the latest commit ID to get the information it
48
-needs.
49
-
50
-In update, call it with a refname followed by a list of commits:
51
-You want to reverse the order git rev-list emits because it lists
52
-from most recent to oldest.
53
-
54
-/path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
contrib/ciabot/README
deleted
-11
@@ -1,11 +0,0 @@
1
-These are hook scripts for the CIA notification service at <http://cia.vc/>
2
-
3
-They are maintained by Eric S. Raymond <esr@thyrsus.com>. There is an
4
-upstream resource page for them at <http://www.catb.org/esr/ciabot/>,
5
-but they are unlikely to change rapidly.
6
-
7
-You probably want the Python version; it's faster, more capable, and
8
-better documented. The shell version is maintained only as a fallback
9
-for use on hosting sites that don't permit Python hook scripts.
10
-
11
-See the file INSTALL for installation instructions.
contrib/ciabot/ciabot.py
deleted
-255
@@ -1,255 +0,0 @@
1
-#!/usr/bin/env python
2
-# Copyright (c) 2010 Eric S. Raymond <esr@thyrsus.com>
3
-# Distributed under BSD terms.
4
-#
5
-# This script contains porcelain and porcelain byproducts.
6
-# It's Python because the Python standard libraries avoid portability/security
7
-# issues raised by callouts in the ancestral Perl and sh scripts. It should
8
-# be compatible back to Python 2.1.5
9
-#
10
-# usage: ciabot.py [-V] [-n] [-p projectname] [refname [commits...]]
11
-#
12
-# This script is meant to be run either in a post-commit hook or in an
13
-# update hook. Try it with -n to see the notification mail dumped to
14
-# stdout and verify that it looks sane. With -V it dumps its version
15
-# and exits.
16
-#
17
-# In post-commit, run it without arguments. It will query for
18
-# current HEAD and the latest commit ID to get the information it
19
-# needs.
20
-#
21
-# In update, call it with a refname followed by a list of commits:
22
-# You want to reverse the order git rev-list emits because it lists
23
-# from most recent to oldest.
24
-#
25
-# /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
26
-#
27
-# Configuration variables affecting this script:
28
-#
29
-# ciabot.project = name of the project
30
-# ciabot.repo = name of the project repo for gitweb/cgit purposes
31
-# ciabot.xmlrpc = if true (default), ship notifications via XML-RPC
32
-# ciabot.revformat = format in which the revision is shown
33
-#
34
-# ciabot.project defaults to the directory name of the repository toplevel.
35
-# ciabot.repo defaults to ciabot.project lowercased.
36
-#
37
-# This means that in the normal case you need not do any configuration at all,
38
-# but setting the project name will speed it up slightly.
39
-#
40
-# The revformat variable may have the following values
41
-# raw -> full hex ID of commit
42
-# short -> first 12 chars of hex ID
43
-# describe = -> describe relative to last tag, falling back to short
44
-# The default is 'describe'.
45
-#
46
-# Note: the CIA project now says only XML-RPC is reliable, so
47
-# we default to that.
48
-#
49
-
50
-import sys
51
-if sys.hexversion < 0x02000000:
52
- # The limiter is the xml.sax module
53
- sys.stderr.write("ciabot.py: requires Python 2.0.0 or later.\n")
54
- sys.exit(1)
55
-
56
-import os, commands, socket, urllib
57
-from xml.sax.saxutils import escape
58
-
59
-# Changeset URL prefix for your repo: when the commit ID is appended
60
-# to this, it should point at a CGI that will display the commit
61
-# through gitweb or something similar. The defaults will probably
62
-# work if you have a typical gitweb/cgit setup.
63
-#
64
-#urlprefix="http://%(host)s/cgi-bin/gitweb.cgi?p=%(repo)s;a=commit;h="
65
-urlprefix="http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id="
66
-
67
-# The service used to turn your gitwebbish URL into a tinyurl so it
68
-# will take up less space on the IRC notification line.
69
-tinyifier = "http://tinyurl.com/api-create.php?url="
70
-
71
-# The template used to generate the XML messages to CIA. You can make
72
-# visible changes to the IRC-bot notification lines by hacking this.
73
-# The default will produce a notification line that looks like this:
74
-#
75
-# ${project}: ${author} ${repo}:${branch} * ${rev} ${files}: ${logmsg} ${url}
76
-#
77
-# By omitting $files you can collapse the files part to a single slash.
78
-xml = '''\
79
-<message>
80
- <generator>
81
- <name>CIA Python client for Git</name>
82
- <version>%(version)s</version>
83
- <url>%(generator)s</url>
84
- </generator>
85
- <source>
86
- <project>%(project)s</project>
87
- <branch>%(repo)s:%(branch)s</branch>
88
- </source>
89
- <timestamp>%(ts)s</timestamp>
90
- <body>
91
- <commit>
92
- <author>%(author)s</author>
93
- <revision>%(rev)s</revision>
94
- <files>
95
- %(files)s
96
- </files>
97
- <log>%(logmsg)s %(url)s</log>
98
- <url>%(url)s</url>
99
- </commit>
100
- </body>
101
-</message>
102
-'''
103
-
104
-#
105
-# No user-serviceable parts below this line:
106
-#
107
-
108
-# Where to ship e-mail notifications.
109
-toaddr = "cia@cia.vc"
110
-
111
-# Identify the generator script.
112
-# Should only change when the script itself gets a new home and maintainer.
113
-generator = "http://www.catb.org/~esr/ciabot.py"
114
-version = "3.6"
115
-
116
-def do(command):
117
- return commands.getstatusoutput(command)[1]
118
-
119
-def report(refname, merged, xmlrpc=True):
120
- "Generate a commit notification to be reported to CIA"
121
-
122
- # Try to tinyfy a reference to a web view for this commit.
123
- try:
124
- url = open(urllib.urlretrieve(tinyifier + urlprefix + merged)[0]).read()
125
- except:
126
- url = urlprefix + merged
127
-
128
- branch = os.path.basename(refname)
129
-
130
- # Compute a description for the revision
131
- if revformat == 'raw':
132
- rev = merged
133
- elif revformat == 'short':
134
- rev = ''
135
- else: # revformat == 'describe'
136
- rev = do("git describe %s 2>/dev/null" % merged)
137
- if not rev:
138
- rev = merged[:12]
139
-
140
- # Extract the meta-information for the commit
141
- files=do("git diff-tree -r --name-only '"+ merged +"' | sed -e '1d' -e 's-.*-<file>&</file>-'")
142
- metainfo = do("git log -1 '--pretty=format:%an <%ae>%n%at%n%s' " + merged)
143
- (author, ts, logmsg) = metainfo.split("\n")
144
- logmsg = escape(logmsg)
145
-
146
- # This discards the part of the author's address after @.
147
- # Might be be nice to ship the full email address, if not
148
- # for spammers' address harvesters - getting this wrong
149
- # would make the freenode #commits channel into harvester heaven.
150
- author = escape(author.replace("<", "").split("@")[0].split()[-1])
151
-
152
- # This ignores the timezone. Not clear what to do with it...
153
- ts = ts.strip().split()[0]
154
-
155
- context = locals()
156
- context.update(globals())
157
-
158
- out = xml % context
159
- mail = '''\
160
-Message-ID: <%(merged)s.%(author)s@%(project)s>
161
-From: %(fromaddr)s
162
-To: %(toaddr)s
163
-Content-type: text/xml
164
-Subject: DeliverXML
165
-
166
-%(out)s''' % locals()
167
-
168
- if xmlrpc:
169
- return out
170
- else:
171
- return mail
172
-
173
-if __name__ == "__main__":
174
- import getopt
175
-
176
- # Get all config variables
177
- revformat = do("git config --get ciabot.revformat")
178
- project = do("git config --get ciabot.project")
179
- repo = do("git config --get ciabot.repo")
180
- xmlrpc = do("git config --get ciabot.xmlrpc")
181
- xmlrpc = not (xmlrpc and xmlrpc == "false")
182
-
183
- host = socket.getfqdn()
184
- fromaddr = "CIABOT-NOREPLY@" + host
185
-
186
- try:
187
- (options, arguments) = getopt.getopt(sys.argv[1:], "np:xV")
188
- except getopt.GetoptError, msg:
189
- print "ciabot.py: " + str(msg)
190
- raise SystemExit, 1
191
-
192
- notify = True
193
- for (switch, val) in options:
194
- if switch == '-p':
195
- project = val
196
- elif switch == '-n':
197
- notify = False
198
- elif switch == '-x':
199
- xmlrpc = True
200
- elif switch == '-V':
201
- print "ciabot.py: version", version
202
- sys.exit(0)
203
-
204
- # The project variable defaults to the name of the repository toplevel.
205
- if not project:
206
- here = os.getcwd()
207
- while True:
208
- if os.path.exists(os.path.join(here, ".git")):
209
- project = os.path.basename(here)
210
- break
211
- elif here == '/':
212
- sys.stderr.write("ciabot.py: no .git below root!\n")
213
- sys.exit(1)
214
- here = os.path.dirname(here)
215
-
216
- if not repo:
217
- repo = project.lower()
218
-
219
- urlprefix = urlprefix % globals()
220
-
221
- # The script wants a reference to head followed by the list of
222
- # commit ID to report about.
223
- if len(arguments) == 0:
224
- refname = do("git symbolic-ref HEAD 2>/dev/null")
225
- merges = [do("git rev-parse HEAD")]
226
- else:
227
- refname = arguments[0]
228
- merges = arguments[1:]
229
-
230
- if notify:
231
- if xmlrpc:
232
- import xmlrpclib
233
- server = xmlrpclib.Server('http://cia.vc/RPC2');
234
- else:
235
- import smtplib
236
- server = smtplib.SMTP('localhost')
237
-
238
- for merged in merges:
239
- message = report(refname, merged, xmlrpc)
240
- if not notify:
241
- print message
242
- elif xmlrpc:
243
- try:
244
- # RPC server is flaky, this can fail due to timeout.
245
- server.hub.deliver(message)
246
- except socket.error, e:
247
- sys.stderr.write("%s\n" % e)
248
- else:
249
- server.sendmail(fromaddr, [toaddr], message)
250
-
251
- if notify:
252
- if not xmlrpc:
253
- server.quit()
254
-
255
-#End
contrib/ciabot/ciabot.sh
deleted
-233
@@ -1,233 +0,0 @@
1
-#!/bin/sh
2
-# Distributed under the terms of the GNU General Public License v2
3
-# Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.org>
4
-# Copyright (c) 2008 Natanael Copa <natanael.copa@gmail.com>
5
-# Copyright (c) 2010 Eric S. Raymond <esr@thyrsus.com>
6
-# Assistance and review by Petr Baudis, author of ciabot.pl,
7
-# is gratefully acknowledged.
8
-#
9
-# This is a version 3.x of ciabot.sh; use -V to find the exact
10
-# version. Versions 1 and 2 were shipped in 2006 and 2008 and are not
11
-# version-stamped. The version 2 maintainer has passed the baton.
12
-#
13
-# Note: This script should be considered obsolete.
14
-# There is a faster, better-documented rewrite in Python: find it as ciabot.py
15
-# Use this only if your hosting site forbids Python hooks.
16
-# It requires: git(1), hostname(1), cut(1), sendmail(1), and wget(1).
17
-#
18
-# Originally based on Git ciabot.pl by Petr Baudis.
19
-# This script contains porcelain and porcelain byproducts.
20
-#
21
-# usage: ciabot.sh [-V] [-n] [-p projectname] [refname commit]
22
-#
23
-# This script is meant to be run either in a post-commit hook or in an
24
-# update hook. Try it with -n to see the notification mail dumped to
25
-# stdout and verify that it looks sane. With -V it dumps its version
26
-# and exits.
27
-#
28
-# In post-commit, run it without arguments. It will query for
29
-# current HEAD and the latest commit ID to get the information it
30
-# needs.
31
-#
32
-# In update, you have to call it once per merged commit:
33
-#
34
-# refname=$1
35
-# oldhead=$2
36
-# newhead=$3
37
-# for merged in $(git rev-list ${oldhead}..${newhead} | tac) ; do
38
-# /path/to/ciabot.sh ${refname} ${merged}
39
-# done
40
-#
41
-# The reason for the tac call is that git rev-list emits commits from
42
-# most recent to least - better to ship notifications from oldest to newest.
43
-#
44
-# Configuration variables affecting this script:
45
-#
46
-# ciabot.project = name of the project
47
-# ciabot.repo = name of the project repo for gitweb/cgit purposes
48
-# ciabot.revformat = format in which the revision is shown
49
-#
50
-# ciabot.project defaults to the directory name of the repository toplevel.
51
-# ciabot.repo defaults to ciabot.project lowercased.
52
-#
53
-# This means that in the normal case you need not do any configuration at all,
54
-# but setting the project name will speed it up slightly.
55
-#
56
-# The revformat variable may have the following values
57
-# raw -> full hex ID of commit
58
-# short -> first 12 chars of hex ID
59
-# describe = -> describe relative to last tag, falling back to short
60
-# The default is 'describe'.
61
-#
62
-# Note: the shell ancestors of this script used mail, not XML-RPC, in
63
-# order to avoid stalling until timeout when the CIA XML-RPC server is
64
-# down. It is unknown whether this is still an issue in 2010, but
65
-# XML-RPC would be annoying to do from sh in any case. (XML-RPC does
66
-# have the advantage that it guarantees notification of multiple commits
67
-# shipped from an update in their actual order.)
68
-#
69
-
70
-# The project as known to CIA. You can set this with a -p option,
71
-# or let it default to the directory name of the repo toplevel.
72
-project=$(git config --get ciabot.project)
73
-
74
-if [ -z $project ]
75
-then
76
- here=`pwd`;
77
- while :; do
78
- if [ -d $here/.git ]
79
- then
80
- project=`basename $here`
81
- break
82
- elif [ $here = '/' ]
83
- then
84
- echo "ciabot.sh: no .git below root!"
85
- exit 1
86
- fi
87
- here=`dirname $here`
88
- done
89
-fi
90
-
91
-# Name of the repo for gitweb/cgit purposes
92
-repo=$(git config --get ciabot.repo)
93
-[ -z $repo] && repo=$(echo "${project}" | tr '[A-Z]' '[a-z]')
94
-
95
-# What revision format do we want in the summary?
96
-revformat=$(git config --get ciabot.revformat)
97
-
98
-# Fully qualified domain name of the repo host. You can hardwire this
99
-# to make the script faster. The -f option works under Linux and FreeBSD,
100
-# but not OpenBSD and NetBSD. But under OpenBSD and NetBSD,
101
-# hostname without options gives the FQDN.
102
-if hostname -f >/dev/null 2>&1
103
-then
104
- hostname=`hostname -f`
105
-else
106
- hostname=`hostname`
107
-fi
108
-
109
-# Changeset URL prefix for your repo: when the commit ID is appended
110
-# to this, it should point at a CGI that will display the commit
111
-# through gitweb or something similar. The defaults will probably
112
-# work if you have a typical gitweb/cgit setup.
113
-#urlprefix="http://${host}/cgi-bin/gitweb.cgi?p=${repo};a=commit;h="
114
-urlprefix="http://${host}/cgi-bin/cgit.cgi/${repo}/commit/?id="
115
-
116
-#
117
-# You probably will not need to change the following:
118
-#
119
-
120
-# Identify the script. The 'generator' variable should change only
121
-# when the script itself gets a new home and maintainer.
122
-generator="http://www.catb.org/~esr/ciabot/ciabot.sh"
123
-version=3.5
124
-
125
-# Addresses for the e-mail
126
-from="CIABOT-NOREPLY@${hostname}"
127
-to="cia@cia.vc"
128
-
129
-# SMTP client to use - may need to edit the absolute pathname for your system
130
-sendmail="sendmail -t -f ${from}"
131
-
132
-#
133
-# No user-serviceable parts below this line:
134
-#
135
-
136
-# Should include all places sendmail is likely to lurk.
137
-PATH="$PATH:/usr/sbin/"
138
-
139
-mode=mailit
140
-while getopts pnV opt
141
-do
142
- case $opt in
143
- p) project=$2; shift ; shift ;;
144
- n) mode=dumpit; shift ;;
145
- V) echo "ciabot.sh: version $version"; exit 0; shift ;;
146
- esac
147
-done
148
-
149
-# Cough and die if user has not specified a project
150
-if [ -z "$project" ]
151
-then
152
- echo "ciabot.sh: no project specified, bailing out." >&2
153
- exit 1
154
-fi
155
-
156
-if [ $# -eq 0 ] ; then
157
- refname=$(git symbolic-ref HEAD 2>/dev/null)
158
- merged=$(git rev-parse HEAD)
159
-else
160
- refname=$1
161
- merged=$2
162
-fi
163
-
164
-# This tries to turn your gitwebbish URL into a tinyurl so it will take up
165
-# less space on the IRC notification line. Some repo sites (I'm looking at
166
-# you, berlios.de!) forbid wget calls for security reasons. On these,
167
-# the code will fall back to the full un-tinyfied URL.
168
-longurl=${urlprefix}${merged}
169
-url=$(wget -O - -q http://tinyurl.com/api-create.php?url=${longurl} 2>/dev/null)
170
-if [ -z "$url" ]; then
171
- url="${longurl}"
172
-fi
173
-
174
-refname=${refname##refs/heads/}
175
-
176
-case $revformat in
177
-raw) rev=$merged ;;
178
-short) rev='' ;;
179
-*) rev=$(git describe ${merged} 2>/dev/null) ;;
180
-esac
181
-[ -z ${rev} ] && rev=$(echo "$merged" | cut -c 1-12)
182
-
183
-# We discard the part of the author's address after @.
184
-# Might be nice to ship the full email address, if not
185
-# for spammers' address harvesters - getting this wrong
186
-# would make the freenode #commits channel into harvester heaven.
187
-author=$(git log -1 '--pretty=format:%an <%ae>' $merged)
188
-author=$(echo "$author" | sed -n -e '/^.*<\([^@]*\).*$/s--\1-p')
189
-
190
-logmessage=$(git log -1 '--pretty=format:%s' $merged)
191
-ts=$(git log -1 '--pretty=format:%at' $merged)
192
-files=$(git diff-tree -r --name-only ${merged} | sed -e '1d' -e 's-.*-<file>&</file>-')
193
-
194
-out="
195
-<message>
196
- <generator>
197
- <name>CIA Shell client for Git</name>
198
- <version>${version}</version>
199
- <url>${generator}</url>
200
- </generator>
201
- <source>
202
- <project>${project}</project>
203
- <branch>$repo:${refname}</branch>
204
- </source>
205
- <timestamp>${ts}</timestamp>
206
- <body>
207
- <commit>
208
- <author>${author}</author>
209
- <revision>${rev}</revision>
210
- <files>
211
- ${files}
212
- </files>
213
- <log>${logmessage} ${url}</log>
214
- <url>${url}</url>
215
- </commit>
216
- </body>
217
-</message>"
218
-
219
-if [ "$mode" = "dumpit" ]
220
-then
221
- sendmail=cat
222
-fi
223
-
224
-${sendmail} << EOM
225
-Message-ID: <${merged}.${author}@${project}>
226
-From: ${from}
227
-To: ${to}
228
-Content-type: text/xml
229
-Subject: DeliverXML
230
-${out}
231
-EOM
232
-
233
-# vim: set tw=70 :