From nobody Mon Sep 16 19:21:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail header.i=fam@euphon.net; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543415788892974.8044974694236; Wed, 28 Nov 2018 06:36:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7D4D89ADD; Wed, 28 Nov 2018 14:36:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84730705A2; Wed, 28 Nov 2018 14:36:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6870F3F953; Wed, 28 Nov 2018 14:36:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wASEaQtA032157 for ; Wed, 28 Nov 2018 09:36:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id DA94B7A5E3; Wed, 28 Nov 2018 14:36:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF6E5611CA; Wed, 28 Nov 2018 14:36:26 +0000 (UTC) Received: from sender1.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by mx1.redhat.com (Postfix) with ESMTP id 1D26B8F51F; Wed, 28 Nov 2018 14:36:16 +0000 (UTC) Received: from localhost.localdomain (123.112.65.99 [123.112.65.99]) by mx.zoho.com.cn with SMTPS id 1543415766829451.7019015454405; Wed, 28 Nov 2018 22:36:06 +0800 (CST) ARC-Seal: i=1; a=rsa-sha256; t=1543415771; cv=none; d=zoho.com.cn; s=zohoarc; b=IE8QLaM8H2HxxzJLVQn9/1MtSRWpHjn1T7lcELRJqV3G8ylMoa52l6tZYgccNqn4FZrZnXryKxVaxlC0gKDEsEmOOzCRwXpG2GOqW5+wBwYaqyDk8OD1tyyJ8MLLviSsLeazAnZlyHhZtNAtF1CFyf+2g4am46TFjlFFtWCRye4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1543415771; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=qpR86G+phxvq89G5Vjp6AKzWUFoSyOLBJwYAqN3jj5E=; b=ALW8OrtuN7LbYYCwOMfL+OmJ8DcIOotHCSJmBIMF4Dgfvu+hPGJTe3xb/fioQeeCMoxUXMv+kI4KgMrmVmcufsBahrTUgQbDAfXVfctd6qXhj68t4r9B00d6kSMDx7tbo8p3hgL6y+dpvuCrCnjjPD22J7IXf4G9jM8ycaz0rL0= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=euphon.net; spf=pass smtp.mailfrom=fam@euphon.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1543415771; s=zoho; d=euphon.net; i=fam@euphon.net; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=5479; bh=qpR86G+phxvq89G5Vjp6AKzWUFoSyOLBJwYAqN3jj5E=; b=KLy1ynNN+Xfwc1nsfAZPza10zST4F3AzP7hLDGqX8yfeuoI9rRZPMLrzzKvVy7WH e6bxLdsAQMq3F9j0IMRLRVV7qcinKllKlyO3sX8IZroVcmZ/MmL1Hqid7HyDq3pvRet xMykjAtiOh0ibkfYhmieQ5I1O5P5ssl72ynaNlPo= From: Fam Zheng To: patchew-devel@redhat.com Date: Wed, 28 Nov 2018 22:35:03 +0800 Message-Id: <20181128143505.27730-11-fam@euphon.net> In-Reply-To: <20181128143505.27730-1-fam@euphon.net> References: <20181128143505.27730-1-fam@euphon.net> X-ZohoCNMailClient: External X-Greylist: Sender passed SPF test, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 28 Nov 2018 14:36:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 28 Nov 2018 14:36:24 +0000 (UTC) for IP:'163.53.93.243' DOMAIN:'sender2-op-o12.zoho.com.cn' HELO:'sender1.zoho.com.cn' FROM:'fam@euphon.net' RCPT:'' X-RedHat-Spam-Score: -0.101 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_PASS) 163.53.93.243 sender2-op-o12.zoho.com.cn 163.53.93.243 sender2-op-o12.zoho.com.cn X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Cc: Fam Zheng Subject: [Patchew-devel] [PATCH v2 10/12] model: Add and populate Message.maintainers X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 28 Nov 2018 14:36:27 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Fam Zheng This is a json field to store a list of str to represent concerned maintainers by the changeset as per MAINTAINERS file in the project (to be processed by appliers). Collect and save maintainers info in applier: if a project has 'scripts/get_maintainer.pl' file, use it to get a list of names associated with the touched files. This is purely ad-hoc (for QEMU) but the logic is standalone and local so it's fairly easy to extend and maybe parameterize later (e.g. add a command in git per-project config). Signed-off-by: Fam Zheng --- api/migrations/0045_message_maintainers.py | 22 +++++++++++++++ api/models.py | 2 ++ mods/git.py | 4 ++- patchew-cli | 31 +++++++++++++++++++--- 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 api/migrations/0045_message_maintainers.py diff --git a/api/migrations/0045_message_maintainers.py b/api/migrations/00= 45_message_maintainers.py new file mode 100644 index 0000000..dbf58c2 --- /dev/null +++ b/api/migrations/0045_message_maintainers.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.16 on 2018-11-20 11:53 +from __future__ import unicode_literals + +from django.db import migrations +import jsonfield.encoder +import jsonfield.fields + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0044_watchedquery'), + ] + + operations =3D [ + migrations.AddField( + model_name=3D'message', + name=3D'maintainers', + field=3Djsonfield.fields.JSONField(blank=3DTrue, default=3D[],= dump_kwargs=3D{'cls': jsonfield.encoder.JSONEncoder, 'separators': (',', '= :')}, load_kwargs=3D{}), + ), + ] diff --git a/api/models.py b/api/models.py index e56f059..897fcc5 100644 --- a/api/models.py +++ b/api/models.py @@ -490,6 +490,8 @@ class Message(models.Model): =20 objects =3D MessageManager() =20 + maintainers =3D jsonfield.JSONField(blank=3DTrue, default=3D[]) + def save_mbox(self, mbox_blob): save_blob(mbox_blob, self.message_id) =20 diff --git a/mods/git.py b/mods/git.py index a37de57..a4290de 100644 --- a/mods/git.py +++ b/mods/git.py @@ -257,11 +257,13 @@ class ApplierReportView(APILoginRequiredView): allowed_groups =3D ["importers"] =20 def handle(self, request, project, message_id, tag, url, base, repo, - failed, log): + failed, log, maintainers=3D[]): p =3D Project.objects.get(name=3Dproject) r =3D Message.objects.series_heads().get(project=3Dp, message_id=3Dmessage_id).gi= t_result r.log =3D log + r.message.maintainers =3D maintainers + r.message.save() data =3D {} if failed: r.status =3D Result.FAILURE diff --git a/patchew-cli b/patchew-cli index b5d6ecb..154aadf 100755 --- a/patchew-cli +++ b/patchew-cli @@ -665,6 +665,20 @@ class ApplyCommand(SubCommand): patch there. Implies --any, conflicts with -C,= -b, -B and -t.""") =20 + def _get_maintainers(self, repo, fname): + script =3D os.path.join(repo, "scripts/get_maintainer.pl") + if not os.access(script, os.X_OK): + return [] + try: + lines =3D subprocess.check_output([script, "--noroles", "--nor= olestats", + "--nogit", "--nogit-fallback", = fname], + cwd=3Drepo).decode('utf-8').splitlines() + # Only return entries in the form of "First Last ", + # excluding list addresses + return [x for x in lines if '<' in x and '>' in x] + except: + return [] + def _apply(self, repo, s, branch, force_branch, tag, logf=3DNone, signoff=3DFalse): msgid =3D s["message-id"] @@ -679,15 +693,21 @@ class ApplyCommand(SubCommand): bn =3D bn.replace("%m", msgid) subprocess.check_call(["git", "checkout", bo, bn], cwd=3Drepo, stdout=3Dlogf, stderr=3Dlogf) + maintainers =3D set() + apply_failed =3D False for p in s["patches"]: patchf =3D tempfile.NamedTemporaryFile() patchf.write(p["mbox"].encode('utf-8')) patchf.flush() + maintainers =3D maintainers.union(self._get_maintainers(repo, = patchf.name)) + if apply_failed: + continue if 0 !=3D subprocess.call(["git", "am", "-m", "-3", patchf.nam= e], cwd=3Drepo, stdout=3Dlogf, stderr=3Dlo= gf): logf.flush() logf.write("Failed to apply patch:\n%s" % p["subject"]) - raise ApplyFailedException() + apply_failed =3D True + continue filter_cmd =3D "" commit_message_lines =3D \ subprocess.check_output(["git", "log", "-n", "1", @@ -711,10 +731,13 @@ class ApplyCommand(SubCommand): subprocess.check_output(["git", "filter-branch", "-f", "--msg-filter", "cat; " + filter_= cmd, "HEAD~1.."], cwd=3Drepo) - if tag: + if apply_failed: + raise ApplyFailedException() + elif tag: subprocess.check_call(["git", "tag", "-f", tag.replace("%m", msgid)], cwd=3Drepo, stdout=3Dlogf, stderr=3Dlogf) + return list(maintainers) =20 def _push(self, repo, remote, tag, logf): subprocess.check_call(["git", "remote", "add", "push_to", remote], @@ -749,7 +772,7 @@ class ApplyCommand(SubCommand): base =3D subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=3Dwd).decode('utf-8') \ .strip() - self._apply(wd, toapply, branch, force_branch, tag, logf) + maintainers =3D self._apply(wd, toapply, branch, force_branch,= tag, logf) if push_repo: self._push(wd, push_repo, tag, logf) url =3D toapply.get("git.url_template", "").replace("%t", tag) @@ -777,7 +800,7 @@ class ApplyCommand(SubCommand): project=3Dtoapply["project"], message_id=3Dtoapply["message-id"], tag=3Dtag, url=3Durl, base=3Dbase, repo=3Dpublic_repo, - failed=3DFalse, log=3Dlog) + failed=3DFalse, log=3Dlog, maintainers=3Dmaintainers) return 0 =20 def do(self, args, argv): --=20 2.17.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel