From bdd71c8f0307a50197b11d6937f9843ef4ad494b Mon Sep 17 00:00:00 2001 From: Sebastian Duda Date: Tue, 3 Aug 2021 14:24:47 +0200 Subject: [PATCH 1/2] pypasta: Add jailhouse to MailCharacteristics extraction Signed-off-by: Sebastian Duda --- pypasta/JailhouseMailCharacteristics.py | 63 +++++++++++++++++++++++++ pypasta/MailCharacteristics.py | 28 +++++++---- pypasta/Repository/Repository.py | 1 + 3 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 pypasta/JailhouseMailCharacteristics.py diff --git a/pypasta/JailhouseMailCharacteristics.py b/pypasta/JailhouseMailCharacteristics.py new file mode 100644 index 00000000..2535e38b --- /dev/null +++ b/pypasta/JailhouseMailCharacteristics.py @@ -0,0 +1,63 @@ +""" +PaStA - Patch Stack Analysis + +Copyright (c) OTH Regensburg, 2021 + +Author: + Sebastian Duda + +This work is licensed under the terms of the GNU GPL, version 2. See +the COPYING file in the top-level directory. +""" + +from .MailCharacteristics import MailCharacteristics, PatchType + + +class JailhouseMailCharacteristics(MailCharacteristics): + ROOT_DIRS = ['ci', + 'configs', + 'Documentation', + 'driver', + 'hypervisor', + 'include', + 'inmates', + 'pyjailhouse', + 'scripts', + 'tools', + ] + ROOT_FILES = ['CONTRIBUTING.md', + 'COPYING', + 'FAQ.md', + '.git', + '.gitignore', + 'Kbuild', + 'LICENSING.md', + 'Makefile', + 'README.md', + 'setup.py', + 'TODO.md', + '.travis.yml', + 'VERSION', + ] + + # Additional lists that are not known by pasta + LISTS = set() + + HAS_MAINTAINERS = False + + def __init__(self, repo, maintainers_version, clustering, message_id): + super().__init__(repo, clustering, message_id) + self.__init(repo, maintainers_version) + self._cleanup() + + def __init(self, repo, maintainers_version): + if self.is_from_bot: + self.type = PatchType.BOT + + if not self.is_patch: + return + + if self.type == PatchType.OTHER: + self.type = PatchType.PATCH + + self._integrated_correct(repo, maintainers_version) diff --git a/pypasta/MailCharacteristics.py b/pypasta/MailCharacteristics.py index bc0df49b..75893846 100644 --- a/pypasta/MailCharacteristics.py +++ b/pypasta/MailCharacteristics.py @@ -174,9 +174,16 @@ def _is_from_bot(self): return False def _integrated_correct(self, repo, maintainers_version): + if self.first_upstream in repo: + upstream = repo[self.first_upstream] + self.committer = upstream.committer.name.lower() + if maintainers_version is None: return + # stuff for maintainers analysis + self.maintainers = dict() + maintainers = maintainers_version[self.version] sections = maintainers.get_sections_by_files(self.patch.diff.affected) for section in sections: @@ -197,8 +204,6 @@ def check_maintainer(section, committer): # integrated by a maintainer that is responsible for a section that is # affected by the patch. IOW: The field indicates if the patch was # picked by the "correct" maintainer - upstream = repo[self.first_upstream] - self.committer = upstream.committer.name.lower() self.integrated_correct = False self.integrated_xcorrect = False sections = maintainers.get_sections_by_files(upstream.diff.affected) @@ -236,6 +241,9 @@ def get_cluster(section): break def list_matches_patch(self, list): + if not self.maintainers: + return None + for lists, _, _ in self.maintainers.values(): if list in lists: return True @@ -262,7 +270,7 @@ def __init__(self, repo, clustering, message_id): self.lists = repo.mbox.get_lists(message_id) # stuff for maintainers analysis - self.maintainers = dict() + self.maintainers = None # Patch characteristics self.is_patch = message_id in repo and message_id not in repo.mbox.invalid @@ -327,11 +335,13 @@ def load_maintainers_characteristics(config, characteristics_class, clustering, ids): repo = config.repo - # We can safely limit to patches only, as only patches will be used for the - # maintainers analysis. - patches = ids - repo.mbox.invalid - tags = {repo.patch_get_version(repo[x]) for x in patches} - maintainers_version = load_maintainers(config, tags) + maintainers_version = None + if characteristics_class.HAS_MAINTAINERS: + # We can safely limit to patches only, as only patches will be used for the + # maintainers analysis. + patches = ids - repo.mbox.invalid + tags = {repo.patch_get_version(repo[x]) for x in patches} + maintainers_version = load_maintainers(config, tags) def _load_characteristics(ret): if ret is None: @@ -373,11 +383,13 @@ def load_characteristics(config, clustering, message_ids = None): config.mbox_timewindow, and loads multiple instances of maintainers for the patches of the clustering. """ + from .JailhouseMailCharacteristics import JailhouseMailCharacteristics from .LinuxMailCharacteristics import LinuxMailCharacteristics from .QemuMailCharacteristics import QemuMailCharacteristics from .UBootMailCharacteristics import UBootMailCharacteristics from .XenMailCharacteristics import XenMailCharacteristics _load_characteristics = { + 'jailhouse': (load_maintainers_characteristics, JailhouseMailCharacteristics), 'linux': (load_maintainers_characteristics, LinuxMailCharacteristics), 'qemu': (load_maintainers_characteristics, QemuMailCharacteristics), 'u-boot': (load_maintainers_characteristics, UBootMailCharacteristics), diff --git a/pypasta/Repository/Repository.py b/pypasta/Repository/Repository.py index 79741cd7..760cb863 100644 --- a/pypasta/Repository/Repository.py +++ b/pypasta/Repository/Repository.py @@ -31,6 +31,7 @@ _tmp_repo = None mainline_regex = { + 'jailhouse': re.compile(r'^v.*$'), 'linux': re.compile(r'^v(\d+\.\d+|2\.6\.\d+)(-rc\d+)?$'), 'qemu': re.compile(r'^v.*$'), 'u-boot': re.compile(r'^v201.*$'), From f5a3b66547eca600665b36ab122579b621b1ffac Mon Sep 17 00:00:00 2001 From: Sebastian Duda Date: Tue, 3 Aug 2021 14:29:16 +0200 Subject: [PATCH 2/2] pypasta: Add more bot filters to pasta Signed-off-by: Sebastian Duda --- pypasta/MailCharacteristics.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pypasta/MailCharacteristics.py b/pypasta/MailCharacteristics.py index 75893846..7e02f2f0 100644 --- a/pypasta/MailCharacteristics.py +++ b/pypasta/MailCharacteristics.py @@ -76,7 +76,7 @@ class MailCharacteristics: BOTS = {'tip-bot2@linutronix.de', 'tipbot@zytor.com', 'noreply@ciplatform.org', 'patchwork@emeril.freedesktop.org'} POTENTIAL_BOTS = {'broonie@kernel.org', 'lkp@intel.com'} - PROCESSES = ['linux-next', 'git pull', 'rfc'] + PROCESSES = ['linux-next', 'git pull', 'rfc', '[PULL]'] @staticmethod def dump_release_info(config): @@ -171,6 +171,18 @@ def _is_from_bot(self): if self.is_next and 'sfr@canb.auug.org.au' in email: return True + # Github Bot + if 'noreply@github.com' in email: + return True + + # Buildroot's daily results bot + if '[autobuild.buildroot.net] Daily results' in subject: + return True + + # Buildroot's daily results bot + if 'oe-core cve metrics' in subject.lower(): + return True + return False def _integrated_correct(self, repo, maintainers_version):