summaryrefslogtreecommitdiff
path: root/contrib/hooks/multimail/README
blob: 5105373aea044f2d8fde0c4fd927c8c492d02585 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
git-multimail version 1.4.0
===========================

.. image:: https://travis-ci.org/git-multimail/git-multimail.svg?branch=master
    :target: https://travis-ci.org/git-multimail/git-multimail

git-multimail is a tool for sending notification emails on pushes to a
Git repository.  It includes a Python module called ``git_multimail.py``,
which can either be used as a hook script directly or can be imported
as a Python module into another script.

git-multimail is derived from the Git project's old
contrib/hooks/post-receive-email, and is mostly compatible with that
script.  See README.migrate-from-post-receive-email for details about
the differences and for how to migrate from post-receive-email to
git-multimail.

git-multimail, like the rest of the Git project, is licensed under
GPLv2 (see the COPYING file for details).

Please note: although, as a convenience, git-multimail may be
distributed along with the main Git project, development of
git-multimail takes place in its own, separate project.  See section
"Getting involved" below for more information.


By default, for each push received by the repository, git-multimail:

1. Outputs one email summarizing each reference that was changed.
   These "reference change" (called "refchange" below) emails describe
   the nature of the change (e.g., was the reference created, deleted,
   fast-forwarded, etc.) and include a one-line summary of each commit
   that was added to the reference.

2. Outputs one email for each new commit that was introduced by the
   reference change.  These "commit" emails include a list of the
   files changed by the commit, followed by the diffs of files
   modified by the commit.  The commit emails are threaded to the
   corresponding reference change email via "In-Reply-To".  This style
   (similar to the "git format-patch" style used on the Git mailing
   list) makes it easy to scan through the emails, jump to patches
   that need further attention, and write comments about specific
   commits.  Commits are handled in reverse topological order (i.e.,
   parents shown before children).  For example::

     [git] branch master updated
     + [git] 01/08: doc: fix xref link from api docs to manual pages
     + [git] 02/08: api-credentials.txt: show the big picture first
     + [git] 03/08: api-credentials.txt: mention credential.helper explicitly
     + [git] 04/08: api-credentials.txt: add "see also" section
     + [git] 05/08: t3510 (cherry-pick-sequence): add missing '&&'
     + [git] 06/08: Merge branch 'rr/maint-t3510-cascade-fix'
     + [git] 07/08: Merge branch 'mm/api-credentials-doc'
     + [git] 08/08: Git 1.7.11-rc2

   By default, each commit appears in exactly one commit email, the
   first time that it is pushed to the repository.  If a commit is later
   merged into another branch, then a one-line summary of the commit
   is included in the reference change email (as usual), but no
   additional commit email is generated. See
   `multimailhook.refFilter(Inclusion|Exclusion|DoSend|DontSend)Regex`
   below to configure which branches and tags are watched by the hook.

   By default, reference change emails have their "Reply-To" field set
   to the person who pushed the change, and commit emails have their
   "Reply-To" field set to the author of the commit.

3. Output one "announce" mail for each new annotated tag, including
   information about the tag and optionally a shortlog describing the
   changes since the previous tag.  Such emails might be useful if you
   use annotated tags to mark releases of your project.


Requirements
------------

* Python 2.x, version 2.4 or later.  No non-standard Python modules
  are required.  git-multimail has preliminary support for Python 3
  (but it has been better tested with Python 2).

* The ``git`` command must be in your PATH.  git-multimail is known to
  work with Git versions back to 1.7.1.  (Earlier versions have not
  been tested; if you do so, please report your results.)

* To send emails using the default configuration, a standard sendmail
  program must be located at '/usr/sbin/sendmail' or
  '/usr/lib/sendmail' and must be configured correctly to send emails.
  If this is not the case, set multimailhook.sendmailCommand, or see
  the multimailhook.mailer configuration variable below for how to
  configure git-multimail to send emails via an SMTP server.


Invocation
----------

``git_multimail.py`` is designed to be used as a ``post-receive`` hook in a
Git repository (see githooks(5)).  Link or copy it to
$GIT_DIR/hooks/post-receive within the repository for which email
notifications are desired.  Usually it should be installed on the
central repository for a project, to which all commits are eventually
pushed.

For use on pre-v1.5.1 Git servers, ``git_multimail.py`` can also work as
an ``update`` hook, taking its arguments on the command line.  To use
this script in this manner, link or copy it to $GIT_DIR/hooks/update.
Please note that the script is not completely reliable in this mode
[1]_.

Alternatively, ``git_multimail.py`` can be imported as a Python module
into your own Python post-receive script.  This method is a bit more
work, but allows the behavior of the hook to be customized using
arbitrary Python code.  For example, you can use a custom environment
(perhaps inheriting from GenericEnvironment or GitoliteEnvironment) to

* change how the user who did the push is determined

* read users' email addresses from an LDAP server or from a database

* decide which users should be notified about which commits based on
  the contents of the commits (e.g., for users who want to be notified
  only about changes affecting particular files or subdirectories)

Or you can change how emails are sent by writing your own Mailer
class.  The ``post-receive`` script in this directory demonstrates how
to use ``git_multimail.py`` as a Python module.  (If you make interesting
changes of this type, please consider sharing them with the
community.)


Troubleshooting/FAQ
-------------------

Please read `<doc/troubleshooting.rst>`__ for frequently asked
questions and common issues with git-multimail.


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

By default, git-multimail mostly takes its configuration from the
following ``git config`` settings:

multimailhook.environment
    This describes the general environment of the repository. In most
    cases, you do not need to specify a value for this variable:
    `git-multimail` will autodetect which environment to use.
    Currently supported values:

    generic
      the username of the pusher is read from $USER or $USERNAME and
      the repository name is derived from the repository's path.

    gitolite
      Environment to use when ``git-multimail`` is ran as a gitolite_
      hook.

      The username of the pusher is read from $GL_USER, the repository
      name is read from $GL_REPO, and the From: header value is
      optionally read from gitolite.conf (see multimailhook.from).

      For more information about gitolite and git-multimail, read
      `<doc/gitolite.rst>`__

    stash
      Environment to use when ``git-multimail`` is ran as an Atlassian
      BitBucket Server (formerly known as Atlassian Stash) hook.

      **Warning:** this mode was provided by a third-party contributor
      and never tested by the git-multimail maintainers. It is
      provided as-is and may or may not work for you.

      This value is automatically assumed when the stash-specific
      flags (``--stash-user`` and ``--stash-repo``) are specified on
      the command line. When this environment is active, the username
      and repo come from these two command line flags, which must be
      specified.

    gerrit
      Environment to use when ``git-multimail`` is ran as a
      ``ref-updated`` Gerrit hook.

      This value is used when the gerrit-specific command line flags
      (``--oldrev``, ``--newrev``, ``--refname``, ``--project``) for
      gerrit's ref-updated hook are present. When this environment is
      active, the username of the pusher is taken