From nobody Fri Oct 25 19:25:06 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524471742282388.6541620162808; Mon, 23 Apr 2018 01:22:22 -0700 (PDT) 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 2F09F356D2; Mon, 23 Apr 2018 08:22:21 +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 1A1976FEF7; Mon, 23 Apr 2018 08:22:21 +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 4ABAF4CAA3; Mon, 23 Apr 2018 08:16:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3N8G14P013017 for ; Mon, 23 Apr 2018 04:16:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id BE7A5781A8; Mon, 23 Apr 2018 08:16:01 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5E69781A7 for ; Mon, 23 Apr 2018 08:15:40 +0000 (UTC) Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D25173002A92 for ; Mon, 23 Apr 2018 08:14:18 +0000 (UTC) Received: by mail-wr0-f175.google.com with SMTP id o15-v6so38563862wro.11 for ; Mon, 23 Apr 2018 01:14:18 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-189-60.clienti.tiscali.it. [78.12.189.60]) by smtp.gmail.com with ESMTPSA id x17sm6468901edx.53.2018.04.23.01.14.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Apr 2018 01:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=2WT2bRuH+Ty60iYdWByFvvCkozfwNyvjoNk+8WOUMG8=; b=BqH6zBG9tqjb73NcQEusNxs4dTqfzoB653Pk1LxyGvdTfsbeM6mT77bBB4/ykjnAXK P+GIdjkY1KYLDdT/4wcCfkn62lz0bqEYXj8gq0vdtjboA9RAZuogWos/oln26p0NdVHb m70pe+ZvsqQA2crqdbEtAaAmz/Nt/4IZfZNGL/CZFhocfmkHOIPBXC9Lr4YIJxCBbruu 7WbRDlUNAi6KgmBE52JW0wI3KIwdfK2wpRurnJ9m+Awd7pyAYk5Tbm9hZ7BIWYVVK0VO csxszoL+NAzOf/iyVihkvpbf7T5rBbts3NOi2GE0n+BGblYbpbtFB/mgBKi3F4PdYL7h ursA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=2WT2bRuH+Ty60iYdWByFvvCkozfwNyvjoNk+8WOUMG8=; b=oU05htInt8TJiEZ1rtO/J2tlUYGuSFCeEoNuNdYsv82LdW5mc3e8+HNorCXGYjZMgG XeETcq9fQG/hozat8V9aGkcZouZE1NFJtCCDFBpEpXb0s1F2GRc13KepQqLQRFrmah6Q A7dHeguQOBL27eIrYy5lbxtkUeMTRqvokSy8sfNss+eZqFJJ0qmy7ZQIsh9298IVmB3w IgUwx14IxlnKRvjDlbDgl9utPeu0OQuXyFFByHirN923BX1KGZqPqeHOiU2cPZHOqkNO /zSfpPs/LR9VJk7Pg2TIhWt8DUJr7buqUSeM8XofTB6Ovzyt8nJe8D0q8/30OzXsujD/ 39Yw== X-Gm-Message-State: ALQs6tDKye5TgBRimeMZV2h9yeMKUFp4Gv0+EF+udP3A8sancxnKSZrp lPz4xJF0qGGFjHKnL/96lV1dFv6h X-Google-Smtp-Source: AIpwx4+Fo2N8bPvJQBwE+bdiAVvwaEoNNzRPV1jvXRYuxZCFyMCRZru+CCE3gR2oDAW+bV8Vb7O1Vw== X-Received: by 10.80.252.12 with SMTP id i12mr10301260edr.74.1524471257161; Mon, 23 Apr 2018 01:14:17 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Mon, 23 Apr 2018 10:14:13 +0200 Message-Id: <20180423081415.15099-3-pbonzini@redhat.com> In-Reply-To: <20180423081415.15099-1-pbonzini@redhat.com> References: <20180423081415.15099-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 23 Apr 2018 08:14:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 23 Apr 2018 08:14:19 +0000 (UTC) for IP:'209.85.128.175' DOMAIN:'mail-wr0-f175.google.com' HELO:'mail-wr0-f175.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.35 (DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.128.175 mail-wr0-f175.google.com 209.85.128.175 mail-wr0-f175.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 2/4] git: add rendering of Results 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.30]); Mon, 23 Apr 2018 08:22:21 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- mods/git.py | 62 +++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/mods/git.py b/mods/git.py index 1f22f2e..3032e39 100644 --- a/mods/git.py +++ b/mods/git.py @@ -122,7 +122,13 @@ class GitModule(PatchewModule): else: git_repo =3D obj.get_property("git.repo") git_tag =3D obj.get_property("git.tag") - data =3D {'repo': git_repo, 'tag': 'refs/tags/' + git_tag} + git_url =3D obj.get_property("git.url") + data =3D {} + if git_repo and git_tag: + data['repo'] =3D git_repo + data['tag'] =3D git_tag + if git_url: + data['url'] =3D git_url status =3D 'success' log_url =3D reverse("git-log", kwargs=3D{'series': obj.message= _id}) else: @@ -130,30 +136,19 @@ class GitModule(PatchewModule): log_url =3D None results.append(Result(name=3D'git', obj=3Dobj, status=3Dstatus, log=3Dlog, log_url=3Dlog_url, data=3Ddata, - request=3Drequest)) + request=3Drequest, renderer=3Dself)) =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: return - l =3D message.get_property("git.apply-log") - if l: - failed =3D message.get_property("git.apply-failed") - log_url =3D reverse("git-log", - kwargs=3D{"series": message.message_id}) - html_log_url =3D log_url + "?html=3D1" - colorbox_a =3D format_html('apply log', - html_log_url, log_url) - if failed: + if message.get_property("git.apply-log"): + if message.get_property("git.apply-failed"): title =3D "Failed in applying to current master" message.status_tags.append({ "title": title, "type": "default", "char": "G", }) - message.extra_status.append({ - "kind": "alert", - "html": format_html('{} ({})', title, colorbox_a), - }) else: git_url =3D message.get_property("git.url") git_repo =3D message.get_property("git.repo") @@ -165,25 +160,12 @@ class GitModule(PatchewModule): "type": "info", "char": "G", }) - if git_repo and git_tag: - message.extra_status.append({ - "kind": "good", - "html": format_html('Patches applied successfu= lly (tree, {}).
git fetch {} {}', - git_url, colorbox_a, git_r= epo, git_tag), - }) else: message.status_tags.append({ "title": format_html("Patches applied successfully= "), "type": "info", "char": "G", }) - message.extra_status.append({ - "kind": "good", - "html": format_html('Patches applied successfully = ({})', - colorbox_a), - "extra": colorbox_div, - "id": "gitlog" - }) if request.user.is_authenticated: if message.get_property("git.apply-failed") !=3D None or \ message.get_property("git.need-apply") =3D=3D None: @@ -195,6 +177,30 @@ class GitModule(PatchewModule): "class": "warning", }) =20 + def render_result(self, result): + if result.status =3D=3D 'pending': + return None + + if result.log_url is not None: + html_log_url =3D result.log_url + "?html=3D1" + colorbox_a =3D format_html('apply log', + html_log_url, result.log_url) + if result.status =3D=3D 'failed': + return format_html('Failed in applying to current master (= {})', title, colorbox_a) + else: + if 'url' in result.data: + s =3D format_html('tree, {}', resul= t.data['url'], colorbox_a) + else: + s =3D colorbox_a + s =3D format_html('Patches applied successfully ({})', s) + if 'repo' in result.data and 'tag' in result.data: + git_repo =3D result.data['repo'] + git_tag =3D result.data['tag'] + if git_tag.startswith('refs/tags/'): + git_tag =3D git_tag[5:] + s +=3D format_html('
git fetch {} {}'= , git_repo, git_tag) + return s + def prepare_project_hook(self, request, project): if not project.maintained_by(request.user): return --=20 2.17.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel