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

Create post-commit git hook to send commit emails

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • N/A
    • OTHER
    • 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

            elenst Elena Stepanova created issue -
            elenst Elena Stepanova made changes -
            Field Original Value New Value
            elenst Elena Stepanova made changes -
            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*.
            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:

            {noformat}
            Commit notification e-mail
            --------------------------

            To configure commit notification e-mails, do the following:

            - install git;
            - clone this tree;
            - (optionally) copy or symlink git_template folder to some <git templates path>;
            - 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;
            - make sure that <git templates path>/hooks/post-commit is executable;
            - (optionally) edit <git templates path>/config file:
              = check that hooks/postcommitrecipients has the desired value;
              = check that hooks/postcommitbranches has the desired value;
              = set hooks/postcommitsender to the e-mail that you want notifications
                to be sent from;
              = configure postcommitmailer if necessary;

            From now on, for all branches listed in hooks/postcommitbranches, commit
            notifications should be sent.

            To disable commit notifications, set SKIP_COMMIT_EMAIL environment variable
            to a non-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

            {noformat}

            Hi Kristian,

            Could you please do a quick review?
            The commit email was sent to the list, otherwise the code can be found here:
            https://github.com/elenst/mariadb-toolbox/tree/master/git_template

            elenst Elena Stepanova added a comment - Hi Kristian, Could you please do a quick review? The commit email was sent to the list, otherwise the code can be found here: https://github.com/elenst/mariadb-toolbox/tree/master/git_template
            elenst Elena Stepanova made changes -
            Assignee Elena Stepanova [ elenst ] Kristian Nielsen [ knielsen ]

            I've mailed a review. I think it looks good as is, just had a couple suggestions for more verbose messages when the commit mail is skipped.

            knielsen Kristian Nielsen added a comment - I've mailed a review. I think it looks good as is, just had a couple suggestions for more verbose messages when the commit mail is skipped.
            knielsen Kristian Nielsen made changes -
            Assignee Kristian Nielsen [ knielsen ] Elena Stepanova [ elenst ]
            elenst Elena Stepanova made changes -
            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:

            {noformat}
            Commit notification e-mail
            --------------------------

            To configure commit notification e-mails, do the following:

            - install git;
            - clone this tree;
            - (optionally) copy or symlink git_template folder to some <git templates path>;
            - 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;
            - make sure that <git templates path>/hooks/post-commit is executable;
            - (optionally) edit <git templates path>/config file:
              = check that hooks/postcommitrecipients has the desired value;
              = check that hooks/postcommitbranches has the desired value;
              = set hooks/postcommitsender to the e-mail that you want notifications
                to be sent from;
              = configure postcommitmailer if necessary;

            From now on, for all branches listed in hooks/postcommitbranches, commit
            notifications should be sent.

            To disable commit notifications, set SKIP_COMMIT_EMAIL environment variable
            to a non-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

            {noformat}
            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:

            {noformat}
            Commit notification e-mail
            --------------------------

            To configure commit notification e-mails, do the following:

            - install git;
            - clone this tree;
            - (optionally) copy or symlink git_template folder to some <git templates path>;
            - 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;
            - make sure that <git templates path>/hooks/post-commit is executable;
            - (optionally) edit <git templates path>/config file:
              = check that hooks/postcommitrecipients has the desired value;
              = check that hooks/postcommitbranches has the desired value;
              = set hooks/postcommitsender to the e-mail that you want notifications
                to be sent from;
              = configure postcommitmailer if necessary;

            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:

            - add the hook script to the tree by either running:
              = cd <cloned folder>
                git init
              = or
                cp <git templates path>/hooks/post-commit <cloned folder>/.git/hooks/

            - copy hooks/postcommit* options from
              <git templates path>/config to <cloned folder>/.git/config


            To disable commit notification(s), set SKIP_COMMIT_EMAIL environment variable
            to a non-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

            {noformat}
            elenst Elena Stepanova added a comment - Pushed to mariadb-tools at launchpad: http://bazaar.launchpad.net/~maria-captains/mariadb-tools/trunk/files/head:/git_template/ http://bazaar.launchpad.net/~maria-captains/mariadb-tools/trunk/revision/259 and to elenst/mariadb-toolbox at github: https://github.com/elenst/mariadb-toolbox/tree/master/git_template
            elenst Elena Stepanova made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            elenst Elena Stepanova made changes -
            Resolution Fixed [ 1 ]
            Status Closed [ 6 ] Reopened [ 4 ]
            elenst Elena Stepanova made changes -
            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:

            {noformat}
            Commit notification e-mail
            --------------------------

            To configure commit notification e-mails, do the following:

            - install git;
            - clone this tree;
            - (optionally) copy or symlink git_template folder to some <git templates path>;
            - 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;
            - make sure that <git templates path>/hooks/post-commit is executable;
            - (optionally) edit <git templates path>/config file:
              = check that hooks/postcommitrecipients has the desired value;
              = check that hooks/postcommitbranches has the desired value;
              = set hooks/postcommitsender to the e-mail that you want notifications
                to be sent from;
              = configure postcommitmailer if necessary;

            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:

            - add the hook script to the tree by either running:
              = cd <cloned folder>
                git init
              = or
                cp <git templates path>/hooks/post-commit <cloned folder>/.git/hooks/

            - copy hooks/postcommit* options from
              <git templates path>/config to <cloned folder>/.git/config


            To disable commit notification(s), set SKIP_COMMIT_EMAIL environment variable
            to a non-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

            {noformat}
            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:

            {noformat}
            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

            {noformat}
            serg Sergei Golubchik made changes -
            Workflow defaullt [ 41601 ] MariaDB v2 [ 44083 ]
            Status Reopened [ 4 ] Stalled [ 10000 ]
            elenst Elena Stepanova added a comment - The official tree for the hook is currently on mariadb-tools on lp: http://bazaar.launchpad.net/~maria-captains/mariadb-tools The script: http://bazaar.launchpad.net/~maria-captains/mariadb-tools/trunk/view/head:/git_template/hooks/post-commit README file: http://bazaar.launchpad.net/~maria-captains/mariadb-tools/trunk/view/head:/git_template/README
            elenst Elena Stepanova made changes -
            Component/s OTHER [ 10125 ]
            Fix Version/s N/A [ 14700 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Workflow MariaDB v2 [ 44083 ] MariaDB v3 [ 65228 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 65228 ] MariaDB v4 [ 132345 ]

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.