First step in merging in the Mercurial support.
[irker.git] / irkerhook.xml
1 <!DOCTYPE refentry PUBLIC 
2    "-//OASIS//DTD DocBook XML V4.1.2//EN"
3    "docbook/docbookx.dtd">
4 <refentry id='irkerhook.1'>
5 <refmeta>
6 <refentrytitle>irkerhook</refentrytitle>
7 <manvolnum>1</manvolnum>
8 <refmiscinfo class='date'>Aug 27 2012</refmiscinfo>
9 <refmiscinfo class='source'>irker</refmiscinfo>
10 <refmiscinfo class='product'>irker</refmiscinfo>
11 <refmiscinfo class='manual'>Commands</refmiscinfo>
12 </refmeta>
13 <refnamediv id='name'>
14 <refname>irkerhook</refname>
15 <refpurpose>repository hook script issuing irker notifications</refpurpose>
16 </refnamediv>
17 <refsynopsisdiv id='synopsis'>
18
19 <cmdsynopsis>
20   <command>irkerhook.py</command>
21      <arg>-n</arg>
22      <arg>-V</arg>
23      <group><arg rep='repeat'><replaceable>--variable=value</replaceable></arg></group>
24      <group><arg rep='repeat'><replaceable>commit-id</replaceable></arg></group>
25 </cmdsynopsis>
26 </refsynopsisdiv>
27
28 <refsect1 id='description'><title>DESCRIPTION</title>
29
30 <para><application>irkerhook.py</application> is a Python script intended 
31 to be called from the post-commit hook of a version-control repository. Its
32 job is to collect information about the commit that fired the hook (and
33 possibly preferences set by the repository owner) and ship that information
34 to an instance of <application>irkerd</application> for forwarding to
35 various announcement channels.</para>
36
37 <para>The proper invocation and behavior of 
38 <application>irkerhook.py</application> varies depending on which
39 VCS (version-control system) is calling it.  There are four different places
40 from which it may extract information:</para>
41
42 <orderedlist>
43 <listitem><para>Calls to VCS utilities.</para></listitem>
44 <listitem><para>In VCSes like git that support user-settable configuration
45 variables, variables with the prefix "irker.".</para></listitem>
46 <listitem><para>In other VCSes, a configuration file, "irker.conf", in the
47 repository's internals directory.</para></listitem>
48 <listitem><para>Command-line arguments of the form
49 --variable=value.</para></listitem>
50 </orderedlist>
51
52 <para>The following variables are general to all supported VCSes:</para>
53
54 <variablelist>
55 <varlistentry>
56 <term>project</term>
57 <listitem>
58 <para>The name of the project.  Should be a relatively short identifier;
59 will usually appear at the very beginning of a notification.</para>
60 </listitem>
61 </varlistentry>
62 <varlistentry>
63 <term>repo</term>
64 <listitem>
65 <para>The name of the repository top-level directory.  If not
66 specified, defaults to a lowercased copy of the project name.</para>
67 </listitem>
68 </varlistentry>
69 <varlistentry>
70 <term>channels</term>
71 <listitem>
72 <para>An IRC channel URL, or comma-separated list of same, identifying
73 channels to which notifications are to be sent. If not specified, the
74 defaults channel list id the freenode #commits channel plus the freenode
75 channel named by the project variable.</para>
76 </listitem>
77 </varlistentry>
78 <varlistentry>
79 <term>server</term>
80 <listitem>
81 <para>The host on which the notification-relaying irker daemon is expected
82 to reside. Defaults to "localhost".</para>
83 </listitem>
84 </varlistentry>
85 <varlistentry>
86 <term>tcp</term>
87 <listitem>
88 <para>If "true", use TCP for communication; if "false", use UDP.
89 Defaults to "false".</para>
90 </listitem>
91 </varlistentry>
92 <varlistentry>
93 <term>urlprefix</term>
94 <listitem>
95 <para>Changeset URL prefix for your repo. When the commit ID is appended
96 to this, it should point at a CGI that will display the commit
97 through cgit,gitweb or something similar. The defaults will probably
98 work if you have a typical gitweb/cgit setup.</para>
99
100 <para>If the value of this variable is "None", generation of the URL
101 field in commit notifications will be suppressed. Other magic values
102 are "cgit", "gitweb", and "viewcvs", which expand to URL templates
103 that will usually work with those systems.</para>
104
105 <para>The magic cookies "%(host)s" and %(repo)s" may occur in this
106 URL.  The former is expanded to the FQDN of the host on which
107 <application>irkerhook.py</application> is running; the latter is
108 expanded to the value of the "repo" variable.</para>
109 </listitem>
110 </varlistentry>
111 <varlistentry>
112 <term>tinyifier</term>
113 <listitem>
114 <para>URL template pointing to a service for compressing URLs so they 
115 will take up less space in the notification line.</para>
116 </listitem>
117 </varlistentry>
118 <varlistentry>
119 <term>color</term>
120 <listitem>
121 <para>If "mIRC", highlight notification fields with mIRC color codes.
122 If "ANSI", highlight notification fields with ANSI color escape sequences.
123 Defaults to "none" (no colors). Note: if you turn this on and
124 notifications stop appearing on your channel, you need to turn off
125 IRC's color filter on that channel.  To do this you will need op
126 privileges; issue the command "/mode #irker -c".  You may need to
127 first issue the command "/msg chanserv set #irker MLOCK
128 +nt-slk".</para>
129 </listitem>
130 </varlistentry>
131 <varlistentry>
132 <term>maxchannels</term>
133 <listitem>
134 <para>Interpreted as an integer. If not zero, limits the number of
135 channels the hook will interpret from the "channels" variable.</para>
136
137 <para>This variable cannot be set through VCS configuration variables
138 or <filename>irker.conf</filename>; it can only be set with a command-line
139 argument.  Thus, on a forge site in which repository owners are not
140 allowed to modify their post-commit scripts, a site administrator can set it 
141 to prevent shotgun spamming by malicious project owners.  Setting it to
142 a value less than 2, however, would probably be unwise.</para>
143 </listitem>
144 </varlistentry>
145 </variablelist>
146
147 <refsect2 id="git"><title>git</title>
148
149 <para>Under git, the normal way to invoke this hook (from within the
150 update hook) passes with a refname followed by a list of commits.  Because 
151 <command>git rev-list</command> normally lists from most recent to oldest,
152 you'll want to use --reverse to make notifications be omitted in chronological
153 order. In a normal update script, the invocation should look like this</para>
154
155 <programlisting>
156 refname=$1
157 old=$2
158 new=$3
159 irkerhook.py --refname=${refname} $(git rev-list --reverse ${old}..${new})
160 </programlisting>
161
162 <para>except that you'll need an absolute path for irkerhook.py.</para>
163
164 <para>For testing purposes and backward compatibility, if you invoke
165 <application>irkerhook.py</application> with no arguments (as in a
166 post-commit hook) it will behave as though it had been called like
167 this:</para>
168
169 <programlisting>
170 irkerhook.py --refname=refs/heads/master HEAD
171 </programlisting>
172
173 <para>However, this will not give the right result when you push to 
174 a non-default branch of a bare repo.</para>
175
176 <para>Preferences may be set in the repo <filename>config</filename>
177 file in an [irker] section. Here is an example of what that can look
178 like:</para>
179
180 <programlisting>
181 [irker]
182     project = gpsd
183     color = ANSI
184     channels = {irc://chat.freenode.net/gpsd, irc://chat.freenode.net/commits}
185 </programlisting>
186
187 <para> You should not set the "repository" variable (an equivalent
188 will be computed). No attempt is made to interpret an
189 <filename>irker.conf</filename> file.</para>
190
191 <para>The default value of the "project" variable is the basename
192 of the repository directory. The default value of the "urlprefix"
193 variable is "cgit".</para>
194
195 <para>There is one git-specific variable, "revformat", controlling
196 the format of the commit identifier in a notification. It
197 may have the following values:</para>
198
199 <variablelist>
200 <varlistentry>
201 <term>raw</term>
202 <listitem><para>full hex ID of commit</para></listitem>
203 </varlistentry>
204 <varlistentry>
205 <term>short</term>
206 <listitem><para>first 12 chars of hex ID</para></listitem>
207 </varlistentry>
208 <varlistentry>
209 <term>describe</term>
210 <listitem><para>describe relative to last tag, falling back to short</para></listitem>
211 </varlistentry>
212 </variablelist>
213
214 <para>The default is 'describe'.</para>
215 </refsect2>
216
217 <refsect2 id="svn"><title>Subversion</title>
218
219 <para>Under Subversion, <application>irkerhook.py</application>
220 requires two arguments: "repository=" (the absolute pathname of the
221 Subversion repository) and "commit=" (the numeric revision level of
222 the commit).  The values must be the two arguments that Subversion
223 gives its post-commit hook. Thus, a typical invocation in the post-commit
224 script will look like this:</para>
225
226 <programlisting>
227 REPO=$1
228 REV=$2
229 irkerhook.py --repository=$REPO $REV
230 </programlisting>
231
232 <para>Other --variable=value settings may also be
233 given on the command line, and will override any settings in an
234 <filename>irker.conf</filename> file.</para>
235
236 <para>The default for the project variable is the basename of the
237 (required) --repository argument.The default value of the "urlprefix"
238 variable is "viewcvs".</para>
239
240 <para>If an <filename>irker.conf</filename> file exists in the repository
241 root directory (not the checkout directory but where internals such as the
242 "format" file live) the hook will interpret variable settings from it.  Here
243 is an example of what such a file might look like:</para>
244
245 <programlisting>
246 # irkerhook variable settings for the irker project
247 project = irker
248 channels  = irc://chat.freenode/irker,irc://chat.freenode/commits
249 tcp = false
250 </programlisting>
251
252 <para>Don't set the "repository" or "commit" variables in this file;
253 that would have unhappy results.</para>
254
255 <para>There are no Subversion-specific variables.</para>
256
257 </refsect2>
258
259 <refsect2 id="hg"><title>Mercurial</title>
260
261 <para>NOTE: Mercurial support is currently broken.  It is expected
262 this will be fixed in the next release.</para>
263
264 <para>Under Mercurial, <application>irkerhook.py</application> can be
265 invoked in two ways: either as a Python hook (preferred) or as a
266 script.  As for git, in both cases all variables may be set in the repo
267 <filename>hgrc</filename> file in an [irker] section.  Command-line
268 variable=value arguments are accepted but not required for script
269 invocation.  No attempt is made to interpret an
270 <filename>irker.conf</filename> file.</para>
271
272 <para>The default value of the "project" variable is the basename
273 of the repository directory. The default value of the "urlprefix"
274 variable is the value of the "web.baseurl" config value, if it
275 exists.</para>
276
277 </refsect2>
278
279 </refsect1>
280
281 <refsect1 id='options'><title>OPTIONS</title>
282
283 <para><application>irkerhook.py</application> takes the following
284 options:</para>
285
286 <variablelist>
287 <varlistentry>
288 <term>-n</term>
289 <listitem><para>Suppress transmission to a daemon. Instead, dump the
290 generated JSON request to standard output. Useful for
291 debugging.</para></listitem>
292 </varlistentry>
293 <varlistentry>
294 <term>-V</term>
295 <listitem><para>Write the program version to stdout and
296 terminate.</para></listitem>
297 </varlistentry>
298 </variablelist>
299
300 </refsect1>
301
302 <refsect1 id='authors'><title>AUTHOR</title>
303 <para>Eric S. Raymond <email>esr@snark.thyrsus.com</email>.  See the
304 project page at <ulink
305 url='http://www.catb.org/~esr/irker'>http://www.catb.org/~esr/irker</ulink>
306 for updates and other resources.</para>
307 </refsect1>
308 </refentry>
309