usefulscripts icon indicating copy to clipboard operation
usefulscripts copied to clipboard

diff code with post-receive git hook

Open mandys opened this issue 5 years ago • 2 comments

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

  •    } elseif(!empty($_POST['signed_request'])) {
    
  •    } elseif(!empty($_POST['signed_request']) && !empty($_POST['appid']) ) {
    

mandys avatar Jul 17 '20 12:07 mandys

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

to git diff $oldrev..$newrev

works.

mandys avatar Jul 17 '20 13:07 mandys

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.

zma avatar Jul 18 '20 04:07 zma