zma / usefulscripts

Useful shell scripts for Linux and macOS
Other
156 stars 155 forks source link

diff code with post-receive git hook #10

Open mandys opened 4 years ago

mandys commented 4 years ago

Hi,

Thank you for the post-receive git hook for sending out an email notification.

I see the following in email

Summary of changes: test_file_2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

Is it possible to send out an actual diff of code that changed ?

Below is just a random example...

diff --git a/test_file_2 b/test_file_2 index 89a15f8..24db903 100644 --- a/test_file_2 +++ b/test_file_2 @@ -176,7 +176,7 @@ class FacebookService

mandys commented 4 years ago

Changing line 434 from git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev

to git diff $oldrev..$newrev

works.

zma commented 4 years ago

Changing line 434 from git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev

to git diff $oldrev..$newrev

works.

Cool. This is useful (but be aware this may generate large emails).

If it can be configured by configs, it may be better. One idea is to use a config like hooks.diffresult ("" or "summary" for the summary; or "fulldiff" for the full git diff) to control the behavior.

If you or anyone would like to make a PR, I will be happy to merge.