Skip to contentSkip to conversation

send an email with logs after push

DISCUSSION michele 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

michele

author
#0 lore raw

Hi guys, I'm using git for a collaborative development and I'm trying to implement a notification system. I want to automatically send an email containing the log of each commit after a push. The email should contain the titles of the commits done between the previous and the last push. The push action publish the repository on a public_html directory in one other machine.

Do you have any suggestion to implement this?

Thanks

#1 lore raw

Michele,

Quoted 1 line

Do you have any suggestion to implement this?

I'm doing that. In the post-receive hook I have:

<<
while read oldrev newrev ref; do
trac_post_receive_record_log "$oldrev" "$newrev" "$ref" gtest

send_mail_post_receive "$oldrev" "$newrev" "$ref" gtest \
[email protected] [email protected]
done

Quoted 1 line
Quoted 1 line

the trac_post_receive_record_log is to add log into trac bug tracker.

the send_mail_post_receive is to send a message to the recipients listed. The 4th parameter is the name of the project.

The send_mail_post_receive function is:

function send_mail_post_receive() {
    oldrev=$1
    newrev=$2
    ref=$3
    MODULE="$4"

    git log -p $oldrev..$newrev > $log
    cat $log | mail -s "[$MODULE] $ref $oldrev..$newrev" $5 $6 $7 $8 $9
    rm -fr $root
}

You'll find a set of hook helper routines there:

git clone http://repo.or.cz/r/git-scripts.git

Hope this helps!

Pascal.

Signature · 8 lines
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
#2 lore raw
Quoted 5 lines · Pascal Obry

Michele,

Quoted 1 line

Do you have any suggestion to implement this?

I'm doing that. In the post-receive hook I have:

See also post-receive-email in git/contrib/hooks/, probably installed somewhere like by your distro. In the .git/hooks/post-receive.sample installed by default by "git init", this should be a matter of uncommenting one line.

--
Matthieu Moy
http://www-verimag.imag.fr/~moy/

author
#3 lore raw
Quoted 1 line · Matthieu Moy

See also post-receive-email in git/contrib/hooks/, probably installed

Thank you for your suggestions. I've added a new post-receive hook using the code from post-receive-email. The hook is executable and is placed in the remote directory. The push is made from my local pc via ssh, but after the push nothing seems to happen: the hook is not executed on the server side. It does not depend from the code inside the hook: even the unique "touch foobar" command does not work. Where do I have to look?

Thanks