Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding git diff in push notification mail

Currently I am using gitolite to mange my repository and users. I successfully setup the notification mail after every push. The command is

chmod a+x post-receive-email
cd /path/to/your/repository.git
ln -sf /usr/share/doc/git-core/contrib/hooks/post-receive-email hooks/post-receive

The notification mail contains only summary of changes. I want to add the Line of changes of each modified file in that push. I am aware of editing that post-receive-email file and have to use git-diff command. My questions are

What is the exact git-diff command I have to use..? Where I have add that command in that post-receive-email file..? Is there any configurations available in gitolite..?

like image 392
arulraj.net Avatar asked Jul 21 '26 19:07

arulraj.net


1 Answers

Update 2021: this is now entirely managed through github.com/git-multimail/git-multimail

With Git 2.33 (Q3 2021), multimail is removed from contrib/ og git itself:

See commit f74d114 (10 Jun 2021) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit 7e24201, 08 Jul 2021)

multimail: stop shipping a copy

Signed-off-by: Johannes Schindelin

The multimail project is developed independently and has its own project page.
Traditionally, we shipped a copy in contrib/.

However, such a copy is prone to become stale, and users are much better served to be directed to the actual project instead.

So the contrib/hooks/multimail I mentioned in 2013 below is no more with git 2.33+ (Q3 2021, 8 years later).


Note: you might be interested in the new git-multimail script, which will be included in git1.8.4 (July 2013)

See commit bc501f69fc6d697968d472afbabe6af97a758b12:

git-multimail: an improved replacement for post-receive-email

Add git-multimail, a tool for generating notification emails for pushes to a Git repository.
It is largely plug-in compatible with post-receive-email, and is proposed to eventually replace that script.
The advantages of git-multimail relative to post-receive-email are described in README.migrate-from-post-receive-email.

git-multimail is organized in a directory contrib/hooks/multimail.

See its independent GitHub project where it is maintained (even though that project will be integrated in contrib/hooks/multimail starting git1.8.4)

You added:

echo ""
echo "Line of changes:"
git diff --diff-filter=M --find-copies-harder --no-prefix --unified=2 $oldrev..$newrev

You would add it in the git_multimail.py python script, just after the diff-tree.
Plus, you can fork the GitHub project, and propose a multimailhook.diffFilterOpts new option, for your diff --diff-filter addition.

like image 162
VonC Avatar answered Jul 24 '26 10:07

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!