From nobody Sat Dec 21 13:21:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1645942446; cv=none; d=zohomail.com; s=zohoarc; b=gmTNcxFiscKup4EZn4azSVF6gCFNtI6VNWXyOXYpH8M6eWHk0PGRlPClrIqZq8LzB0JToQJlIEtxMWAs3Ueb43pSW/hz7L9pEv9doEgYang0VnupA33T0NAU4wVA+2nfew+acTyOpR5wzusEoLUm/uY7pa7Ssblfjlr+s/8fZsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645942446; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=BSojfxWklboCEMQOCwhYW+fvHSwSN7lCt0APYIn2EVE=; b=nPY7+yhS0F2+1AKmbI0Vl1bHlHVP0A81OXzAf4a0jPTyCf/WMsxs0Rgwdn9x1orugO4FO10PwWNyjvah5TjOCR3EEWL46iF2uspEsT9OFiivLAWDc8GW4b1gK/ooJnqT66ApNGJoGuajV5TpVFXF2fSE7DRqB1R+1B9EceL/UU0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645942446538882.4162730047677; Sat, 26 Feb 2022 22:14:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-524-SK0bLqzhOq6tKAnJzvjICw-1; Sun, 27 Feb 2022 01:14:02 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B32C51006AA5; Sun, 27 Feb 2022 06:14:00 +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 AA50D646A9; Sun, 27 Feb 2022 06:14:00 +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 722B544A5A; Sun, 27 Feb 2022 06:14:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21R6DHW8017008 for ; Sun, 27 Feb 2022 01:13:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 013117CAEE; Sun, 27 Feb 2022 06:13:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A2F57D5A8 for ; Sun, 27 Feb 2022 06:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645942445; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BSojfxWklboCEMQOCwhYW+fvHSwSN7lCt0APYIn2EVE=; b=dc1frwVKqu3E6OOMPRvO+g9DYEhkLNX7DBNj8VM1c99lzPmDqxP5h237YObM/5U8RDS0Vo EpwhflJTAKWjIIJbIcoDJeLXQvyc/9ueRng0niZa6rOMrCWh6MTy4wrfZx8iKfdD726Jkq ATYhPu6cDxAjngLoCPjb/tcGA59vT0I= X-MC-Unique: SK0bLqzhOq6tKAnJzvjICw-1 From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sun, 27 Feb 2022 07:13:05 +0100 Message-Id: <20220227061305.37045-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] rest: only return projects with configured target_repo from series/unapplied/ 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: , Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645942447930100004 Content-Type: text/plain; charset="utf-8" The filtering was only applied if a target repo was provided in the query parameters. Do it always (though really, what we should do is not create a "pending" result if a target repo is not configured). Signed-off-by: Paolo Bonzini --- mods/git.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/mods/git.py b/mods/git.py index ea9fd54..bcaab7c 100644 --- a/mods/git.py +++ b/mods/git.py @@ -297,27 +297,25 @@ class GitModule(PatchewModule): =20 def pending_series(self, target_repo): q =3D Message.objects.filter(results__name=3D"git", results__statu= s=3D"pending") - if target_repo is not None and target_repo !=3D "": - # Postgres could use JSON fields instead. Fortunately project= s are - # few so this is cheap - def match_target_repo(config, target_repo): - push_to =3D config.get("git", {}).get("push_to") - if push_to is None: - return False - if target_repo[-1] !=3D "/": - return push_to =3D=3D target_repo or push_to.startswit= h( - target_repo + "/" - ) - else: - return push_to.startswith(target_repo) =20 - projects =3D Project.objects.values_list("id", "config").all() - projects =3D [ - pid - for pid, config in projects - if match_target_repo(config, target_repo) - ] - q =3D q.filter(project__pk__in=3Dprojects) + # Postgres could use JSON fields instead. Fortunately projects are + # few so this is cheap + def match_target_repo(config, target_repo): + push_to =3D config.get("git", {}).get("push_to") + if push_to is None: + return False + if target_repo is None or target_repo =3D=3D "": + return True + elif target_repo[-1] !=3D "/": + return push_to =3D=3D target_repo or push_to.startswith(ta= rget_repo + "/") + else: + return push_to.startswith(target_repo) + + projects =3D Project.objects.values_list("id", "config").all() + projects =3D [ + pid for pid, config in projects if match_target_repo(config, t= arget_repo) + ] + q =3D q.filter(project__pk__in=3Dprojects) return q =20 =20 --=20 2.34.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel