From patchwork Tue May 21 14:41:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13669491 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0ABFA13D29F for ; Tue, 21 May 2024 14:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716302517; cv=none; b=Mz79TuaG73Qhg5ih/8i5FzwQ7jw7kkKcx+QmddU0d7J/jX+elWF1hm53M0a6jdQqZYuKo0i0I8OfStA/eSio/a+4v4KafR+VopqHQ7Sd5fNewYCtRYoLjfeKlu4EL94ymCGh/aVKviE2i5TZzxj64tKmI2WoXzcHjhS6e8BZk+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716302517; c=relaxed/simple; bh=C4xXUJWGjBRwNncPXB8R9t8RvaWMX4Ng+0mLjI0MQ5E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WC6gGXEubTeCxRx9nv3rodvS+/N3RLdAbbGuDTVjS81yXkK9RXisWZbygeihiGa7KTiH1J5X0q5ZIZtXJKcdX4IWVu19CiLfSMYaX4EflbyX/lILEjKEoUaWizT0C4wOTMf5W3FTwFcN6BRsj6nn1O4jxmaZE7xiN7oRBkEKuVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=BlJ0+7pW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="BlJ0+7pW" Received: by smtp.kernel.org (Postfix) id E3103C4AF09; Tue, 21 May 2024 14:41:56 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 3A48EC32789 for ; Tue, 21 May 2024 14:41:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org 3A48EC32789 Authentication-Results: smtp.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 655931C0006; Tue, 21 May 2024 14:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716302513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v8MbadUMiVpDrqt/BO2VZj3ZhgedcAx92CPjfz5nr0c=; b=BlJ0+7pW7uJKSOWgpazO7un+f/wqHkxr6itnsPxXi1/q+IZhzEwzNZQo26gvQah3NPdYvP 4xSf9NAfnt1piN+penOR1ddOsICivO83+9HAwbozqOe5EW2s0j1kjQcbgtsQKx8aoOyZZC 2u0q87Q2NvIgC2mh23RolX1S6ZJjvzoq2ueBJSgICT7dQEeOV8cxhNzPav4wDnQ5AmksWk Ga7nOyoi/iCefW7fS9rkoHxFvwRwnaRwYC+68sNwIjb0ST7X1RfemT3z44bzC5rvMAbaCD AysEQQ02P/0JR+NcS/5xLxcdtnNRuFsCi6K8Dk/SzKWfN2u/R5naJiAa2fKHTw== From: Louis Chauvet Date: Tue, 21 May 2024 16:41:37 +0200 Subject: [PATCH b4 1/2] ez: Ensure that all the info dict keys are defined Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240521-fix-check-deps-v1-1-d149bf40e7ee@bootlin.com> References: <20240521-fix-check-deps-v1-0-d149bf40e7ee@bootlin.com> In-Reply-To: <20240521-fix-check-deps-v1-0-d149bf40e7ee@bootlin.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Louis Chauvet X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5170; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=C4xXUJWGjBRwNncPXB8R9t8RvaWMX4Ng+0mLjI0MQ5E=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmTLKw4yhdyJ/BTla7LO2xQ2+T4eUNquOYDrRDR 7DcFmwcgqyJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZkyysAAKCRAgrS7GWxAs 4oIvEACyyMCp5BUFe7D93OQ4sZu2OccsKC/MQK7rR3v1E222F84q24upg9jKPNM3z6L2mDCKPys skTmo9ZAs8vQrgCcBk2KaaP5V4kbNL4lqpSxWegeEjF66m7K/umHewuprzcQVzZ9nrN9IGJM21n XZs9wfzSlRep1d3SBWO9SHqQGGcQmyTsPwgOoC+wLUBhXj3s4hPlVzEjpA2Ct/S2Yh8ByTRN+wX PxSlm3NHYu0TkVKXqoLtOQ0GWuCf6lbGhNUa8TQ1T89SzjsQHR98d6RxxYE5k2pCBzzGnHp97Np iVl0Xbrjdvx2v0yh349F9hhhsCxx+tZyUAhfqgBxlzZktZIybEb9s5IjN4AgzZfPqFPHojiAPxo ZiPbsu1jRFcI0QHtRKnA8W2y7mdO+VO3k8q+44goPTD9w0CRrhYegGNuNit27jH9FwSQsXCcCYQ aSezDX5Ydmm61Mrigpq4uTivBPSifmFn8zTruc4GWA3sKZRw6YADq89tkjP5nf9tIAaalCsJD/1 GHbhBwJAU+GabwLGQaxqqE+6HNpQ9YH7auoDB+N+5jJS7ZfBYJdlon/83/WayfcrH58kUdnRvrA adOYs4YdAFyEFP/15XVqK/eNWCbItABuDR9M7FJjY/jNjyq5n8M8fNQv9ZCaZ+JykACBX1ZdBnP 22FR2meK8hG0fow== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com In some situations, a few keys in the info dictionary were not defined, which could lead to "KeyError" errors (for example, 'needs-auto-to-cc' and 'needs-checking' were not always defined). To prevent these errors and simplify the code logic, I used a literal dictionary initialization for the info dictionary. --- src/b4/ez.py | 74 ++++++++++++++++++++++++++---------------------------------- 1 file changed, 32 insertions(+), 42 deletions(-) diff --git a/src/b4/ez.py b/src/b4/ez.py index e1a4d67696ad..76121ab02d03 100644 --- a/src/b4/ez.py +++ b/src/b4/ez.py @@ -2401,7 +2401,8 @@ def show_info(param: str) -> None: prep_info = get_info(usebranch=mybranch) if getval == '_all': for key, val in prep_info.items(): - print('%s: %s' % (key, val)) + if val is not None: + print('%s: %s' % (key, val)) elif getval in prep_info: print(prep_info[getval]) else: @@ -2411,57 +2412,46 @@ def show_info(param: str) -> None: def get_info(usebranch: str) -> Dict[str, str]: is_prep_branch(mustbe=True, usebranch=usebranch) - info = dict() - info['branch'] = usebranch cover, tracking = load_cover(usebranch=usebranch) csubject, cbody = get_cover_subject_body(cover) - info['cover-subject'] = csubject.full_subject ts = tracking['series'] - if ts.get('prefixes'): - info['prefixes'] = ' '.join(ts.get('prefixes')) - info['change-id'] = ts.get('change-id') - revision = ts.get('revision') - info['revision'] = revision - strategy = get_cover_strategy(usebranch=usebranch) - info['cover-strategy'] = strategy - if ts.get('base-branch'): - info['base-branch'] = ts['base-branch'] base_commit, start_commit, end_commit, oneline, shortlog, diffstat = get_series_details(usebranch=usebranch) - info['needs-editing'] = False todests, ccdests, tag_msg, patches = get_prep_branch_as_patches(usebranch=usebranch, expandprereqs=False) - if not todests and not ccdests: - info['needs-recipients'] = True - else: - info['needs-recipients'] = False - if b'EDITME' in b4.LoreMessage.get_msg_as_bytes(patches[0][1]): - info['needs-editing'] = True prereqs = tracking['series'].get('prerequisites', list()) - info['has-prerequisites'] = len(prereqs) > 0 tocmd, cccmd = get_auto_to_cc_cmds() - if tocmd or cccmd: - info['needs-auto-to-cc'] = True ppcmds, scmds = get_check_cmds() - if ppcmds or scmds: - info['needs-checking'] = True pf_checks = get_preflight_checks(usebranch=usebranch) - if pf_checks is not None: - if (tocmd or cccmd) and 'auto-to-cc' in pf_checks and not info['needs-recipients']: - info['needs-auto-to-cc'] = False - if (ppcmds or scmds) and 'check' in pf_checks: - info['needs-checking'] = False - if info['has-prerequisites']: - info['needs-checking-deps'] = 'check-deps' not in pf_checks - else: - info['needs-checking-deps'] = False - if info['needs-editing'] or info['needs-auto-to-cc'] or info['needs-checking'] or info['needs-checking-deps']: - info['preflight-checks-failing'] = True - else: - info['preflight-checks-failing'] = False - info['base-commit'] = base_commit - info['start-commit'] = start_commit - info['end-commit'] = end_commit - info['series-range'] = f'{start_commit}..{end_commit}' + info = { + # General information about this branch + 'branch': usebranch, + 'cover-subject': csubject.full_subject, + 'base-branch': ts.get('base-branch'), + 'base-commit': base_commit, + 'start-commit': start_commit, + 'end-commit': end_commit, + 'series-range': f'{start_commit}..{end_commit}', + + # General information about this branch status + 'prefixes': ' '.join(ts.get('prefixes', [])) or None, + 'change-id': ts.get('change-id'), + 'revision': ts.get('revision'), + 'cover-strategy': get_cover_strategy(usebranch=usebranch), + + # General information about this branch checks + 'needs-editing': b'EDITME' in b4.LoreMessage.get_msg_as_bytes(patches[0][1]), + 'needs-recipients': bool(not todests and not ccdests), + 'has-prerequisites': len(prereqs) > 0, + 'needs-auto-to-cc': None, + 'needs-checking': bool(ppcmds or scmds) and 'check' not in pf_checks, + 'needs-checking-deps': len(prereqs) > 0 and 'check-deps' not in pf_checks, + 'preflight-checks-failing': None, + } + info['needs-auto-to-cc'] = info["needs-recipients"] or (bool(tocmd or cccmd) and 'auto-to-cc' not in pf_checks) + info['preflight-checks-failing'] = bool(info['needs-editing'] or info['needs-auto-to-cc'] or + info['needs-checking'] or info['needs-checking-deps']) + + # Add commits information for line in oneline: short, subject = line.split(maxsplit=1) info[f'commit-{short}'] = subject From patchwork Tue May 21 14:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13669492 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F300513D29F for ; Tue, 21 May 2024 14:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716302518; cv=none; b=RJiH+AOsofBrqYAtsTW9K4BxsDKoIDfqqiGlKUm9+ORc9e6Tooy7mIZPCUreq0UEzZ3PvbUYxKjn+ikzb4ZF3ArRbkd49mpBEnSgos4sXS07psuNPF+S9nLjLXYvbFEIgShUoNQsqcLXS/qU/S63OelKWDV+VT3vpdWr6zL28Ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716302518; c=relaxed/simple; bh=lfthrnbyIw7JKLeF+EDc5zc4v+/W3gwrgAxx7c7c02c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZK3cUKwcUlD8dRLSDdf1eJhsaUVa9a7KGJtH8M7K855izM2YmTEGn2Mc/gmBrWdigB3In+Uw9iPPib+hQ2fiu3AB5gvOg/eackSVQtqTKba3xTdhtvt+MVnVxZX7DAsCxcDNCK3w5YHehRdUuOEKXwophXdieUxbzlS2j2zuSiE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=HwMCndxe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HwMCndxe" Received: by smtp.kernel.org (Postfix) id C635DC32786; Tue, 21 May 2024 14:41:57 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 749A1C4AF08 for ; Tue, 21 May 2024 14:41:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org 749A1C4AF08 Authentication-Results: smtp.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id AC8261C000D; Tue, 21 May 2024 14:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716302513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4+gwLf5MUNEs7zqdDSVT2Baa1TZzXMcFg7oGGXlnwSY=; b=HwMCndxeFanxZ9MOnTi9tzzj91CP+5wPgjtQpgC/ky9PqxXqcyYWeciyCt6DCZ1fbR6/aK 9jbMJB2JpV5CvfXeyawnb3phtpQwQ7x2zWmRnOA2qkuUChtFwKVsz5Fgk2UtUyplsy7Z1b aWAmeHhRDwgHuvFWHiM72bc87jtBOjzi945mg1WS33ADKa1skaHrAKj/SU7JKubdhqY+HU a1GpxtQQpa9Hee8qWxvo1lgNq5WPuI1lGy86megmrnY/Vx9Yi1jSRWKWy0fjEetzmGCiRB MxOPKc7qttJA56/+6Xp7SDoninLUiLspEtcyve7U9pCoQvOdbXen1v0r4wTjtw== From: Louis Chauvet Date: Tue, 21 May 2024 16:41:38 +0200 Subject: [PATCH b4 2/2] ez: Fix check-deps when strategy is commit Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240521-fix-check-deps-v1-2-d149bf40e7ee@bootlin.com> References: <20240521-fix-check-deps-v1-0-d149bf40e7ee@bootlin.com> In-Reply-To: <20240521-fix-check-deps-v1-0-d149bf40e7ee@bootlin.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Louis Chauvet X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1948; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=lfthrnbyIw7JKLeF+EDc5zc4v+/W3gwrgAxx7c7c02c=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmTLKwZ4lZuF/GAgzsSUzzQFMESu8pCeVCbsJnE sMTDV8WDsaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZkyysAAKCRAgrS7GWxAs 4hh7EACSN3Q4WB5NmWIzId4qdSX6H1/p01F5kJEl5DuWcYUgEwhWUf3zRmwUOytMDCEnC/4r6EF bHu0XKc2yJ4lygiDe9EU6ogel3IzjWwGdHT0KV7cC72BR0xhIZi2xghTeTWdfzNfndrtDbrsJVE qE52t7vMoUbCFecAzT3/Tv7HynrvJ4sdd8fXjQlgSRjMDepIQp5kl5SwN5M/MUpIAWnEejhlOQV fyE59sgtU+Gd7joRWJLX56clIvmCD4n+r0oggHlyhnuizVBswydsE2r1ed8wn0uqsN2pp0Z8F6W fnsYf6E/dr8aHAE7ZMG32y6mJfsQ7k/qKIBWij9P6RTqJSt41XnSPYPH6Xga2WiO7Yv+4APTz6R P5f9ZFsA9R/V+e5Ua0EHqZJmS7A3SuWjjJ8Sszdq+XYKxg8NHCi+Bynk1zqQfzbx+mjFH5jYDE2 k49gC9yvHbOQHzXnkTm96gqVDAlILrCf8CFPDFdWMCQ2lX1vg6HmbcLl4vjBV00VWx1lZqvn0KY LVj5E1SFbhapb3TqB+ZcIU5pfI/HMXdta/4Czbe9PsmL2viM1O4HRVQWT85e+YCg8WP3uSA0MEN waSUe0aAV26jmtAJOn984WYWw008hYbzk456n0gEJWVe1n3pCmvXt9nHfjhTBonB2BWcZUQaSwx sQUd5g7VXKhf4mw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com When using the commit strategy for the cover letter, the first commit is empty. This commit can't be applied properly with git am, so just skip it. Signed-off-by: Louis Chauvet --- I tested to use --empty=drop/keep, but the error was the same, maybe because there are many patches to apply at the same time? --- src/b4/ez.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/b4/ez.py b/src/b4/ez.py index 76121ab02d03..5e6ed7f90900 100644 --- a/src/b4/ez.py +++ b/src/b4/ez.py @@ -919,7 +919,11 @@ def check_deps(cmdargs: argparse.Namespace) -> None: elif allgood: logger.info('Testing if all patches can be applied to %s', base_commit) tos, ccs, tstr, mypatches = get_prep_branch_as_patches(thread=False, movefrom=False, addtracking=False) - prereq_patches += [x[1] for x in mypatches] + if get_cover_strategy() == "commit": + # If the cover letter is stored as a commit, skip it to avoid empty patches + prereq_patches += [x[1] for x in mypatches[1:]] + else: + prereq_patches += [x[1] for x in mypatches] gitdir = os.getcwd() topdir = b4.git_get_toplevel(gitdir) if b4.git_commit_exists(topdir, base_commit): @@ -2451,7 +2455,9 @@ def get_info(usebranch: str) -> Dict[str, str]: info['preflight-checks-failing'] = bool(info['needs-editing'] or info['needs-auto-to-cc'] or info['needs-checking'] or info['needs-checking-deps']) - # Add commits information + # Add informations about the commits in this series + # `commit-`: stores the subject of each commit + # `series-`: stores the commit range for a particular revision for line in oneline: short, subject = line.split(maxsplit=1) info[f'commit-{short}'] = subject