Git hook to send email notification on repo changes

前端 未结 11 1872
情深已故
情深已故 2020-11-28 01:33

How do I configure the appropriate Git hook to send a summary email whenever a set of changes is pushed to the upstream repository?

相关标签:
11条回答
  • 2020-11-28 02:09

    setting hooks.showrev is making no distinguishable difference? :-/

    Sample conf:

    # less users/cj.git/config 
    [core]
            repositoryformatversion = 0
            filemode = true
            bare = true
    [hooks]
            mailinglist = cj@yoga.ee
            showrev = "git show -C %s; echo"
            emailprefix = "[sabu gitosis server] "
    
    0 讨论(0)
  • 2020-11-28 02:09

    I managed to do this, but had to opt for using the contrib script, not the other (perl) script by Alexandre Julliard. It seems fancier and more configurable, but with postfix I had no mail command which would accept "-s"? Here's my way:

    http://pastie.textmate.org/695323

    It would be nice to show some more info, like the full patch, gitweb link and commit graph as well, but this script can only do the first - if I play around with hooks.showrev it seems.

    Anyway, cheers and thanks for the suggestions!

    0 讨论(0)
  • 2020-11-28 02:10

    If you use GitLab you can use the 'Email-on-push' project service for this, it can be found under services in project settings.

    0 讨论(0)
  • 2020-11-28 02:15

    In GitLab under your repository:

    1. Click on Setting.
    2. When setting expands there you will see Integrations. Click on it.

    There opens a new page Emails on push

    1. Locate and select Send from committer.
    2. Also, enter the Recipients with comma separated located at the last field.

    Also there is an option for Disable code diffs which exclude possibly sensitive code diffs in notification body. It is optional.

    For more details: Click Here

    0 讨论(0)
  • 2020-11-28 02:18

    Robin Sommer's git-notifier generates also very nice summaries in the following format:

    Subject: [git/git-notifier] master: Adding www target to Makefile. (7dc1f95)
    
    Repository : ssh://<removed>/git-notifier
    
    On branch  : master
    
    >---------------------------------------------------------------
    
    commit 7dc1f95c97275618d5bde1aaf6760cd7ff6a6ef7
    Author: Robin Sommer <robin@icir.org>
    Date:   Sun Dec 19 20:21:38 2010 -0800
    
        Adding www target to Makefile.
    
    >---------------------------------------------------------------
    
     Makefile |    6 ++++++
     1 files changed, 6 insertions(+), 0 deletions(-)
    
    diff --git a/Makefile b/Makefile
    index e184c66..9c9951b 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -5,6 +5,8 @@ VERSION   = 0.1
    
     DISTFILES = git-notifier README COPYING
    
    +WWW = $(HOME)/www/git-notifier
    +
     all:
    
     dist:
    @@ -13,3 +15,7 @@ dist:
        cp $(DISTFILES) git-notifier-$(VERSION)
        tar czvf git-notifier-$(VERSION).tgz git-notifier-$(VERSION)
        rm -rf git-notifier-$(VERSION)
    +
    +www: dist
    +   rst2html.py README >$(WWW)/index.html
    +   cp git-notifier-$(VERSION).tgz $(WWW)
    
    0 讨论(0)
  • 2020-11-28 02:24

    Another, more modern way to do this is with git-multimail, as suggested by Chords below.


    This is how you did it in 2009.

    You could add something like this to your post-receive hook in $GITDIR/hooks, or use the script in the contrib directory of the source (Available here)

    0 讨论(0)
提交回复
热议问题