From patchwork Thu Mar 5 14:54:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1972 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1772722530; bh=HnrBvlmZLu8eiVTT7Hmi1vtQN4zeKfW7nTplhWq4rd4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=OTjVccPpgYNMV5VsHzE/UxgcWmipkYSUtHkhik6WP1VJcQWQE39fi6WE1qR/9nk2S xGHi2TDECadKlGMDWJLOPe55dEzJLjF9m4/bM1Q/2NRirr2rxYG0O319XPtI2m2PRR xXf7PIU0idKt7E0p2mPPx450Kme1pDsdUfa5d+M7Z20aJOwg91F98oQyRpGnHb+jEt IAfsy/EuK34u0D5lhaqWkOxd2X++cJk31Y68q7CNy5vaOasjYQFq/fR3XE8sdEJ1Oy zdn79IDSYVHZmzUOjwqL5hwhq4cBRuR6zm2exLb2NgGT/wDwgG68e7k+kCdRme0hxj 8rYvavxVsQaQg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 28B6A69F25 for ; Thu, 5 Mar 2026 07:55:30 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id JWAD-jdvq11E for ; Thu, 5 Mar 2026 07:55:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1772722530; bh=HnrBvlmZLu8eiVTT7Hmi1vtQN4zeKfW7nTplhWq4rd4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=OTjVccPpgYNMV5VsHzE/UxgcWmipkYSUtHkhik6WP1VJcQWQE39fi6WE1qR/9nk2S xGHi2TDECadKlGMDWJLOPe55dEzJLjF9m4/bM1Q/2NRirr2rxYG0O319XPtI2m2PRR xXf7PIU0idKt7E0p2mPPx450Kme1pDsdUfa5d+M7Z20aJOwg91F98oQyRpGnHb+jEt IAfsy/EuK34u0D5lhaqWkOxd2X++cJk31Y68q7CNy5vaOasjYQFq/fR3XE8sdEJ1Oy zdn79IDSYVHZmzUOjwqL5hwhq4cBRuR6zm2exLb2NgGT/wDwgG68e7k+kCdRme0hxj 8rYvavxVsQaQg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 14B7469F0F for ; Thu, 5 Mar 2026 07:55:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1772722527; bh=VbxFIymALPYOhNZdt53Oin+CdAzYHma6kPAIddpGmtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFRmL8vl9YV7PXzv1YRKQzi21XkofrzlRWxqVmCnlcvsbj/RpekI7W0Y0wYaLOhNU h7oB3tLeHhMBxh6FsuG+vdtA39DxqKwKsR96bRkAxmyuCjUgrBI6F98SDBQX8UWVn0 L35MIoWVTXREZdJknISdIU6QHXXCUTNwrtfAS2Va996g2r54qtWkNf12DpkvaGfjv0 YfqtT4TN7BJnSh9PYJPnfQQ8q0Vmjx3lojbrJrq/UzWJMkelT1+SbMjT/ueNe0Py9l YKgTMgzt+sooMQR8PbDby5cNwVqaASVwkfbyN19SyUs2UxNpMDXXJKBSyhw1WLCJUp lyBZ+NLUQe7+w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9BD3669D92; Thu, 5 Mar 2026 07:55:27 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id CWlFz5-wZxWp; Thu, 5 Mar 2026 07:55:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1772722523; bh=lCN1fa3+7sAzha/LQjYp2RvakRkehkuoGkgyUJhVE/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHjownYsVze0gGIax4BsvWhz7Tn1C0TpjE/8iGGvfaiYlV9gVOgrU267tF+86hdPP iLt2Ym99vv2lrHJ1La3tt+yIOMuhdDM5n7QXtcPJEl7wiuH0mcL9osSCRguW9rEbY2 npvUl04Hi81/fz4wLahxGMUC4axItLoIQz87rzKAmBEw2BC4n/ZmFvnX+jCiWF9NKa ERlxbZgSX3YdNhCgDXmPp+DBFHxXFO/VXPYAU3SYQqqrG/mFuAAWcilNyj7svQXHPE 2iEAtw9fk98SNWZFv5tlCVlaELUWO4hNO/8MD/E+74xtRvOW0L0W8WLTh5OYDsgC+T j2fnErUhJORYA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3E46C69EC0; Thu, 5 Mar 2026 07:55:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 5 Mar 2026 07:54:46 -0700 Message-ID: <20260305145452.909661-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260305145452.909661-1-sjg@u-boot.org> References: <20260305145452.909661-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HKWOFEUN3X2EHV2MVZB3KLDRVOGUKDB5 X-Message-ID-Hash: HKWOFEUN3X2EHV2MVZB3KLDRVOGUKDB5 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 3/4] pickman: Fix push_branch() to raise on failure List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass push_branch() catches CommandExc and returns False on failure, but callers like apply_subtree_update() use try/except to detect push failures rather than checking the return value. This means push failures are silently ignored and the source is advanced even though the branch was not pushed. Change push_branch() to re-raise the CommandExc instead of returning False, and update all callers to use exception handling consistently. This ensures apply_subtree_update() properly aborts when a push fails. Signed-off-by: Simon Glass --- tools/pickman/control.py | 9 ++++++--- tools/pickman/ftest.py | 6 ++++-- tools/pickman/gitlab_api.py | 9 +++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/pickman/control.py b/tools/pickman/control.py index ed6825c2333..6d787d02163 100644 --- a/tools/pickman/control.py +++ b/tools/pickman/control.py @@ -2080,9 +2080,12 @@ def do_push_branch(args, dbs): # pylint: disable=unused-argument int: 0 on success, 1 on failure """ skip_ci = not args.run_ci - success = gitlab_api.push_branch(args.remote, args.branch, args.force, - skip_ci=skip_ci) - return 0 if success else 1 + try: + gitlab_api.push_branch(args.remote, args.branch, args.force, + skip_ci=skip_ci) + except command.CommandExc: + return 1 + return 0 def do_commit_source(args, dbs): diff --git a/tools/pickman/ftest.py b/tools/pickman/ftest.py index 590677d6b5b..95053e78d21 100644 --- a/tools/pickman/ftest.py +++ b/tools/pickman/ftest.py @@ -4956,8 +4956,10 @@ class TestDoPushBranch(unittest.TestCase): tout.init(tout.INFO) args = argparse.Namespace(cmd='push-branch', branch='test-branch', remote='ci', force=False, run_ci=False) - with mock.patch.object(gitlab, 'push_branch', - return_value=False): + with mock.patch.object( + gitlab, 'push_branch', + side_effect=command.CommandExc( + 'push failed', command.CommandResult())): with terminal.capture(): ret = control.do_push_branch(args, None) self.assertEqual(ret, 1) diff --git a/tools/pickman/gitlab_api.py b/tools/pickman/gitlab_api.py index 81918c80c3c..4d90d622dbc 100644 --- a/tools/pickman/gitlab_api.py +++ b/tools/pickman/gitlab_api.py @@ -196,6 +196,9 @@ def push_branch(remote, branch, force=False, skip_ci=True): Returns: bool: True on success + + Raises: + command.CommandExc: If the push fails """ try: # Use token-authenticated URL if available @@ -232,7 +235,7 @@ def push_branch(remote, branch, force=False, skip_ci=True): return True except command.CommandExc as exc: tout.error(f'Failed to push branch: {exc}') - return False + raise # pylint: disable=too-many-arguments @@ -630,7 +633,9 @@ def push_and_create_mr(remote, branch, target, title, desc=''): return None tout.info(f'Pushing {branch} to {remote}...') - if not push_branch(remote, branch, force=True): + try: + push_branch(remote, branch, force=True) + except command.CommandExc: return None tout.info(f'Creating merge request to {target}...')