Search code examples
gitgit-post-receive

Do not flood with post-receive emails during GIT repo creation


I am trying to stop the flood of emails for the first time of GIT repo creation. For example, let us say I am moving from SVN to GIT and I do not want to get the flood of emails for the commits already created in SVN.

I would also like to know the use cases when I can stop flooding of emails for already existing commits.

I am planning to do this from post-receive hook and I am using gitolite.


Solution

  • while (<>) 
    {
                chomp;
                    next unless ($old_rev, $new_rev ,$ref_name) =
                        m/ ^ ([0-9a-f]+) \s+    # old SHA-1
                             ([0-9a-f]+) \s+    # new SHA-1
                             (.*?) # ref_name
                         \s* $ /x;
    
                my $send_email = _git_cmd_exec("git config hooks.sendmailalert");
    
                if ($send_email) {
                    generate_and_send_mail();
                }
            }