public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC Git hooks
@ 2019-09-14 20:53 Jason Merrill
  2019-09-15  1:54 ` Joseph Myers
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Jason Merrill @ 2019-09-14 20:53 UTC (permalink / raw)
  To: brobecker, Joseph S. Myers
  Cc: Maxim Kuvyrkov, gcc Mailing List, Gerald Pfeifer, Daniel Berlin

[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]

At Cauldron this weekend Joel offered to adjust his git hooks
(https://github.com/brobecke/git-hooks), which are already used by gdb
and glibc, to meet GCC's needs.  Separately, Joseph volunteered to
deal with converting the gcc-www repository to git and dealing with
those hooks.

I expect that Joel's hooks should work fine for gcc-www with minimal
changes, but that the main GCC repository will need more work for
bugzilla integration.

The GCC SVN hooks initially look like pretty vanilla SVN hooks using
svnmailer (http://opensource.perlig.de/svnmailer/); the customized
part of the svnmailer.conf is just

[libstdcxx]
for_paths = .*(libstdc..-v3)/.*
to_addr = libstdc++-cvs@gcc.gnu.org

[java]
for_paths = .*(boehm-gc|fastjar|gcjx|gcc/java|libffi|libjava|zlib)/.*
to_addr = java-cvs@gcc.gnu.org

[gccdefault]
to_addr = gcc-cvs@gcc.gnu.org
bugzilla_to_addr = gcc-bugzilla@gcc.gnu.org

Pretty short...but the last line relies on Daniel's custom
bugzilla/svnmailer integration (attached below), and it looks like
Joel's hooks don't have anything comparable.  Any thoughts about
adjusting Daniel's bugzilla.py vs. pulling in something like
http://www.theoldmonk.net/gitzilla/ ?

Jason

[-- Attachment #2: bugzilla.py --]
[-- Type: text/x-python, Size: 4518 bytes --]

# -*- coding: utf-8 -*-
#
# Copyright 2004-2006 André Malo or his licensors, as applicable
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Bugzilla based email notifiers (either piped to a program or via SMTP)
"""
__author__    = "Daniel Berlin"
__docformat__ = "epytext en"
__all__       = ['getNotifier']

handled_bugs = {}

def getNotifier(config, groupset):
    """ Returns an initialized notifier or nothing

        @param config: The svnmailer config
        @type config: C{svnmailer.settings.Settings}

        @param groupset: The groupset to process
        @type groupset: C{list}

        @return: The list of notifiers (containing 0 or 1 member)
        @rtype: C{list}
    """
    from svnmailer import settings
    from svnmailer.notifier import _textmail, _multimail

    cls = None
    if config.general.sendmail_command:
        cls = SendmailSubmitter
    elif config.general.smtp_host:
        cls = SMTPSubmitter

    if cls:
        mtype = (groupset.groups[0].mail_type or u'single').split()[0].lower()
        is_commit = (config.runtime.mode == settings.modes.commit)
        mod = (is_commit and mtype == u'multipart') and \
            _multimail or _textmail
        return mod.getNotifier(cls, config, groupset)

    return []


class SMTPSubmitter(object):
    """ Use SMTP to submit the mail """
    _settings = None

    def sendMail(self, sender, to_addr, mail):
        """ Sends the mail via SMTP """
        import smtplib, cStringIO

        fp = cStringIO.StringIO()
        mail.dump(fp)
        mail = fp.getvalue()
        fp.close()

        general = self._settings.general
        conn = smtplib.SMTP(general.smtp_host)
        if general.smtp_user:
            conn.login(general.smtp_user, general.smtp_pass)

        conn.sendmail(sender, to_addr, mail)
        conn.quit()


class SendmailSubmitter(object):
    """ Pipe all stuff to a mailer """
    _settings = None

    def sendMail(self, sender, to_addr, mail):
        """ Sends the mail via a piped mailer """
        global handled_bugs
        from svnmailer import util
        import sys
        import re
        import cStringIO
        bugre = re.compile('\s+(?:bug|PR|BZ)\s+\#?\s*(?:[a-z\-\+]+\/)?(?:\/)?(\d+)(.*)$',re.I | re.S | re.M)
        start = 0
        fp = cStringIO.StringIO()
        mail.dump(fp)
        mailtxt = fp.getvalue()
        fp.close()
        result = bugre.search(mailtxt, start)
        while result:
          try:
            bugnum = result.group(1)
            if handled_bugs.has_key(bugnum) == False:
              for group in [group for group in self._groupset.groups if group.bugzilla_to_addr]:
                handled_bugs[bugnum] = True
                mail.replace_header('To', group.bugzilla_to_addr)
                mail.replace_header('Subject',"[Bug %s]" % (bugnum, ))
                pipe = util.getPipe2(self._getMailCommand(sender, [group.bugzilla_to_addr]))
                pipe.fromchild.close() # we don't expect something
                mail.dump(pipe.tochild)
                pipe.tochild.close()

                # what do we do with the return code?
                pipe.wait()
            start = result.span(1)[1]
            result = bugre.search(mailtxt, start)
          except:
            result = None
            break

    def _getMailCommand(self, sender, to_addr):
        """ Returns the mailer command

            The command is created using sendmail conventions.
            If you want another commandline, override this method.

            @param sender: The sender address
            @type sender: C{str}

            @param to_addr: The receivers
            @type to_addr: C{list}

            @return: The command
            @rtype: C{list}
        """
        cmd = list(self._settings.general.sendmail_command)
        cmd[1:] = [(isinstance(arg, unicode) and
            [arg.encode("utf-8")] or [arg])[0] for arg in cmd[1:]
        ]
        cmd.extend(['-f', sender])
        cmd.extend(to_addr)

        return cmd

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-01-13 17:20 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-14 20:53 GCC Git hooks Jason Merrill
2019-09-15  1:54 ` Joseph Myers
2019-09-15  3:50 ` Gerald Pfeifer
2019-09-15 12:07   ` Joseph Myers
2019-09-15 16:16     ` Gerald Pfeifer
2019-09-16 15:11       ` Joel Brobecker
2019-09-16 20:02       ` Joseph Myers
2019-09-17 11:13         ` Gerald Pfeifer
2019-09-17 12:55           ` Joel Brobecker
2019-09-17 15:56           ` Joseph Myers
2019-09-16 15:06 ` Joel Brobecker
2019-09-26 12:41   ` Joel Brobecker
2020-01-09 14:26   ` Joseph Myers
2020-01-09 22:07     ` Joseph Myers
2020-01-10 11:03       ` Jonathan Wakely
2020-01-10 13:06         ` Joseph Myers
2020-01-10 13:38           ` Jonathan Wakely
2020-01-10 15:53       ` Joseph Myers
2020-01-10 18:00         ` Joel Brobecker
2020-01-10 18:15           ` Joseph Myers
2020-01-10 18:22             ` Joel Brobecker
2020-01-10 18:24               ` Joseph Myers
2020-01-10 18:40                 ` Joel Brobecker
2020-01-10 20:44         ` Joseph Myers
2020-01-13 20:47           ` Joseph Myers
2020-01-10 17:57       ` Joel Brobecker
2020-01-10 17:38     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).