Example #1
0
    def _guest_module_name(self):
        lists = execute_shell("cd %s ; git log -n 20 --pretty=format:%%s %s ; echo" % (self._repo, self._fname))

        modules = {}
        mcount = 0
        module = ''
        capcnt = 0
        total = 0
        for m in lists:
            if m.find(":") != -1:
                if re.match('\w+\s*:\s*\w+\s*- ', m):
                    mname = re.match('\w+\s*:\s*\w+\s*-', m).group(0).strip()
                else:
                    mname = re.sub(':[^:]*$', "", m).strip()
                # start with 'Merge ....'
                if mname.find('Merge ') != -1:
                    continue
                if len(mname) == 0:
                    continue
                _ptitle = m.replace(mname, '')[1:].strip()
                if _ptitle[0] == _ptitle[0].upper():
                    capcnt += 1
                total += 1
                if module.find("%s:" % mname) != -1:
                    continue
                if modules.has_key(mname):
                    modules[mname] += 1
                    if mcount < modules[mname]:
                        mcount = modules[mname]
                        module = mname
                    elif mname.find("%s:" % module) != -1:
                        # make sure 'module: submodule:' exists at least twice
                        mcount = modules[mname]
                        module = mname
                else:
                    modules[mname] = 1
                    if module == '':
                        module = mname

        if len(module) == 0:
            module = self._dirname()

        self._module = module
        if total < capcnt * 2:
            self._capitalize = True
        else:
            self._capitalize = False
        return module
Example #2
0
    def _guest_email_list(self):
        mailto = []
        mailcc = []
        nolkml = True
        skiplkml = False
        commit_signer = ''
        commit_signer_list = []
        _re_list = [{'cc': ['[email protected]', '[email protected]'],
                     'rmto': ['David S. Miller <[email protected]>', '"David S. Miller" <[email protected]>'],
                     'rmcc': ['[email protected]']},
                    {'cc': ['[email protected]'], 'rmto': [],
                     'rmcc': ['[email protected]']}]

        lists = execute_shell("cd %s ; /usr/bin/perl ./scripts/get_maintainer.pl -f %s --remove-duplicates --nogit" % (self._repo, self._fname))
        for m in lists:
            # skip User <mail> (commit_signer:1/15=7%)
            if re.search('\(commit_signer:', m) != None:
                csm = re.sub('\([^>]*\)$', '', m)
                if len(commit_signer) == 0:
                    commit_signer = csm
                commit_signer_list.append(csm)
                continue
            m = re.sub('\([^>]*\)$', '', m).strip()
            if re.search(r'<.*>', m) != None:
                mailto.append(m)
            elif re.search('[email protected]', m) != None:
                if len(mailcc) == 0:
                    mailcc.append(m)
                else:
                    skiplkml = True
            else:
                if re.search('@vger.kernel.org', m) != None:
                    nolkml = False
                if len(m.strip()) != 0:
                    mailcc.append(m)

        if nolkml == True and skiplkml == True:
            mailcc.append('[email protected]')

        for rml in _re_list:
            for cc in rml['cc']:
                if mailcc.count(cc) != 0:
                    for rto in rml['rmto']:
                        if mailto.count(rto) != 0:
                            mailto.remove(rto)
                    for rcc in rml['rmcc']:
                        if mailcc.count(rcc) != 0:
                            mailcc.remove(rcc)
                    break

        if mailcc.count('[email protected]') != 0 or mailcc.count('[email protected]') != 0:
            if mailcc.count('[email protected]') != 0:
                mailcc.remove('[email protected]')
            if mailto.count('David S. Miller <[email protected]>') != 0:
                mailto.remove('David S. Miller <[email protected]>')
            if mailto.count('"David S. Miller" <[email protected]>') != 0:
                mailto.remove('"David S. Miller" <[email protected]>')

        if len(mailto) == 0 and mailcc.count('[email protected]') != 0:
            mailto.append('David S. Miller <[email protected]>')

        if read_config('git.use_commit_singer', True):
            for m in commit_signer_list:
                mailto.append(m)
        else:
            if len(mailto) == 0 and len(commit_signer) != 0:
                mailto.append(commit_signer)

        elist = ""
        if len(mailto) != 0:
            elist += "To: %s" % mailto[0].strip()
            to = mailto[1:]
            for t in to:
                elist += ",\n    %s" % t.strip()
        if len(mailcc) != 0:
            prefix = 'Cc'
            # to list may be null
            if len(mailto) == 0:
                prefix = 'To'
            elist += "\n%s: %s" % (prefix, mailcc[0].strip())
            cc = mailcc[1:]
            for c in cc:
                elist += ",\n    %s" % c.strip()
        elist += '\n'

        self._mlist = elist

        return elist