Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6278

Create post-commit git hook to send commit emails

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Fix Version/s: N/A
    • Component/s: OTHER
    • Labels:
      None

      Description

      There is a post-commit hook in git, all that's needed is a script that would send an email including the commit diff.

      Contents of the README file:

      Commit notification e-mail
      --------------------------
       
      To configure commit notification e-mails for the first time, do the following:
       
      - the following should be done regardless commit notification:
        = install git;
        = run git config --global user.name "<Your Name>"
        = run git config --global user.email "<your email>"
      - clone/pull this tree (further it's location is <this tree>);
      - create a folder <git templates>;
      - symlink <this tree>/git_template/hooks to <git templates path>/hooks;
      - configure git templates location globally:
        = for git versions >= 1.7.1, run 
          git config --global init.templatedir <git templates path>
        = for older git versions, set the environmemnt variable 
          GIT_TEMPLATE_DIR=<git templates path> 
          and make sure it is always set whenever you work with git;
      - run git config --global hooks.postcommitrecipients "<comma-separated list of addresses to send emails to>;
      - run git config --global hooks.postcommitbranches "<space-separated list of branches> (* wildcard is allowed)
      - optionally:
        = run git config --global hooks.postcommitsender <e-mail to send notifications from> 
        = run git config --global hooks.postcommitmailer <path to mailer> 
          if anything other than /usr/sbin/sendmail is to be used
      - make sure <this tree>/git_template/hooks/post-commit-email is executable;
       
      Example (most common set of commands):
       
      bzr branch lp:mariadb-tools 
      mkdir $HOME/.git_template/
      ln -s `pwd`/mariadb-tools/git_template/hooks $HOME/.git_template/hooks
      git config --global init.templatedir $HOME/.git_template
      git config --global hooks.postcommitrecipients "commits@mariadb.org"
      git config --global hooks.postcommitbranches "*"
       
      From now on, for all new clones of branches listed in hooks/postcommitbranches, 
      commit notifications should be sent. 
       
      If you had already cloned some trees before enabling commit notifications, 
      you will need to amend those trees:
       
      cd <cloned folder>
      rm -rf .git/hooks
      ln -s <this tree>/git_template/hooks .git/hooks
       
       
      To disable commit notification(s), set SKIP_COMMIT_EMAIL environment variable 
      to a non-empty value or set hooks.postcommitbranches to an empty value.
       
       
      Notes:
       
      - hooks/postcommitrecipients is a *comma-separated* list of e-mails. Normally, 
        it is expected to contain the commit mailing list, but you can add some other
        address(es) or change it if you wish;
      - hooks/postcommitbranches is a *space-separated* list of branches affected 
        by the post-commit hook. Asterisk wildcard is allowed. 
        Please note that these are *real* git branches, as opposed to branch nicknames. 
       
      Examples:
       
      Assuming you did the following
        git clone https://github.com/MariaDB/server 10.1-mdev1234
        ...
        git branch
        # * 10.1
        git commit -a
       
       Example 1:
        postcommitbranches = 10.0 10.1 10.2
        # The commit e-mail will be sent because the current branch is 10.1, 
        # it's on the list
       
        Example 2:
        postcommitbranches = 10.0-* 10.1-* 10.2-*
        # The commit e-mail won't be sent because the current branch is 10.1, 
        # it does not match the pattern 10.1-*
       
        Example 3:
        postcommitbranches = 10*
        # The commit e-mail will be sent
       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              elenst Elena Stepanova
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: