views:

3163

answers:

5

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

+14  A: 

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)

mwalling
If I reference that script in my hooks, does the referenced script have to reside on the upstream host or locally?
Head
The host that is executing the hook, so in the case of a post-receive, the upstream host (whereas a post-commit hook would need the script on the host you're running the commit on).
mwalling
Thanks, if I had more karma I'd upvote your answer. ;-)
Head
Ahhh, but you can accept the answer and you'll both get more reputation!
Pat Notz
+1  A: 

The syntax for adding / customizing the script, for example for this particular purpose, is not crystal clear. I think both scripts are pretty multi-purpose, are they equivalent?

Anyway, thanks for the answer and link, I will sure be using it!

UncleCJ
+1  A: 

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!

UncleCJ
+3  A: 

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

Sample conf:

# less users/cj.git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[hooks]
        mailinglist = [email protected]
        showrev = "git show -C %s; echo"
        emailprefix = "[sabu gitosis server] "
UncleCJ
Ah, turns out the git.kernel.org version respected hooks.showrev, but default git installation script didn't! Just replaced the script, chmod a+x and then it works! Still need to understand the showrev syntax though
UncleCJ
Similar issues with showing diffs here: http://stackoverflow.com/questions/804601/git-post-receive-email-hook-including-diff-patches/1790161#1790161
UncleCJ
+1  A: 

This is my way of send email notification to users every time some one push to the repository.

http://pkill.info/blog/post/setting-up-git-commit-email-notification.html

It's based on Andy Parkins's scripts. I change it to used SMTP to send email. Of course, gmail's SMTP can also be used.

Eric