summaryrefslogtreecommitdiff
path: root/contrib/hooks/multimail/doc/gitolite.rst
blob: 00aedd9c579f9acc2c94dc8632f2c2b9fa2c96bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Setting up git-multimail on gitolite
====================================

``git-multimail`` supports gitolite 3 natively.
The explanations below show an easy way to set up ``git-multimail``,
but leave ``git-multimail`` installed and unconfigured for a while. If
you run gitolite on a production server, it is advised that you
execute the step "Set up the hook" last to avoid confusing your users
in the meantime.

Set up the hook
---------------

Log in as your gitolite user.

Create a file ``.gitolite/hooks/common/post-receive`` on your gitolite
account containing (adapt the path, obviously)::

  #!/bin/sh
  exec /path/to/git-multimail/git-multimail/git_multimail.py "$@"

Make sure it's executable (``chmod +x``). Record the hook in
gitolite::

  gitolite setup

Configuration
-------------

First, you have to allow the admin to set Git configuration variables.

As gitolite user, edit the line containing ``GIT_CONFIG_KEYS`` in file
``.gitolite.rc``, to make it look like::

  GIT_CONFIG_KEYS                 =>  'multimailhook\..*',

You can now log out and return to your normal user.

In the ``gitolite-admin`` clone, edit the file ``conf/gitolite.conf``
and add::

  repo @all
      # Not strictly needed as git_multimail.py will chose gitolite if
      # $GL_USER is set.
      config multimailhook.environment = gitolite
      config multimailhook.mailingList = # Where emails should be sent
      config multimailhook.from = # From address to use

Obviously, you can customize all parameters on a per-repository basis by
adding these ``config multimailhook.*`` lines in the section
corresponding to a repository or set of repositories.

To activate ``git-multimail`` on a per-repository basis, do not set
``multimailhook.mailingList`` in the ``@all`` section and set it only
for repositories for which you want ``git-multimail``.

Alternatively, you can set up the ``From:`` field on a per-user basis
by adding a ``BEGIN USER EMAILS``/``END USER EMAILS`` section (see
``../README``).

Specificities of Gitolite for Configuration
-------------------------------------------

Empty configuration variables
.............................

With gitolite, the syntax ``config multimailhook.commitList = ""``
unsets the variable instead of setting it to an empty string (see
`here
<http://gitolite.com/gitolite/git-config.html#an-important-warning-about-deleting-a-config-line>`__).
As a result, there is no way to set a variable to the empty string.
In all most places where an empty value is required, git-multimail
now allows to specify special ``"none"`` value (case-sensitive) to
mean the same.

Alternatively, one can use ``" "`` (a single space) instead of ``""``.
In most cases (in particular ``multimailhook.*List`` variables), this
will be equivalent to an empty string.

If you have a use-case where ``"none"`` is not an acceptable value and
you need ``" "`` or  ``""`` instead, please report it as a bug to
git-multimail.

Allowing Regular Expressions in Configuration
.............................................

gitolite has a mechanism to prevent unsafe configuration variable
values, which prevent characters like ``|`` commonly used in regular
expressions. If you do not need the safety feature of gitolite and
need to use regular expressions in your configuration (e.g. for
``multimailhook.refFilter*`` variables), set
`UNSAFE_PATT
<http://gitolite.com/gitolite/git-config.html#unsafe-patt>`__ to a
less restrictive value.

Troubleshooting
---------------

Warning: this will disable ``git-multimail`` during the debug, and
could confuse your users. Don't run on a production server.

To debug configuration issues with ``git-multimail``, you can add the
``--stdout`` option when calling ``git_multimail.py`` like this::

  #!/bin/sh
  exec /path/to/git-multimail/git-multimail/git_multimail.py --stdout "$@"

and try pushing from a test repository. You should see the source of
the email that would have been sent in the output of ``git push``.