Pergunta

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..?

Foi útil?

Solução

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.

Outras dicas

According to githooks(5), you can make a post-receive script that gets every line of stdin (a.k.a., the affected branches), logs each commit between the first and second field (cut -d' ' -f1, cut -d' ' -f2), and git shows each of those commits.

Store all that info in a variable, and mail it - then you're done.

I think you can start by copying your post-receive-email hook into your hooks directory (instead of linking it), and then modifying it to have your new email body.

If you post your current hook script it could be easier to tell you how to modify it.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top