Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA69DC0015E for ; Sun, 16 Jul 2023 00:43:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 86B0B86660; Sun, 16 Jul 2023 02:39:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="WOw3IDpd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D20F88639E; Sun, 16 Jul 2023 02:38:03 +0200 (CEST) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9460E86351 for ; Sun, 16 Jul 2023 02:37:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-786bb09e595so95187939f.1 for ; Sat, 15 Jul 2023 17:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467870; x=1692059870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D5Atoza+EnIJPufbKO3vgZxh81oRaMq/ulIjR55RDwQ=; b=WOw3IDpdsl68sgzYZq7RYcc9whB752aNbbYhSIzqEOUtR2kMzgthbfMoPmc7ACh9EA uIPd0E10TUPUuSvSqNyLEzSaFgfHzolWvF6NwlsyOGzvNpPyKs8pW8Bexme3nkIltihR 4Xn497QGSc0F+bl4RKRZvBj9Pt+RR2SNXz+KM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467870; x=1692059870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D5Atoza+EnIJPufbKO3vgZxh81oRaMq/ulIjR55RDwQ=; b=O2NXRduXqcJZn767/EUplcu+JGiPdZDud11nZ8JGQt8/8pQOw+yl1WJey4A/bnxumk ucdHniu5/q2Yx3pC6nJJb0gh0y1XSGdDZib+yBZGSGwBe11CEBClVzIioPyHQWSc4n9K mg09TRaZm0wk9P6NAPZ8WB9nQZ4ei8bXmC3fEj/iFDUAF1Yg/E/XBtbUgU0r78/BzbIJ m/KNfPMuT3IkzSoPog96MJqVGR2X6CF3X5dSYYqjvVWOCrCxo7ahhJWAUAIzsuzfiZOg K5YVjed7hyduHiPgKmQPlKMILMYRPAfQMEQHoDxjnJjoNYG4jJAsk4TJkfcVtf0oSJh4 nykA== X-Gm-Message-State: ABy/qLbTkm3iqfQypDRBf2U2/6u7hvsXNI3bg+Op3T8fthfwjkCOw69U szBWEuwEQFqot1jvFePQIFr7PmA2zUkCUNsfCJk= X-Google-Smtp-Source: APBJJlEQscbEGIAvJMIb4Na4xwCOJHAYkVLyvvoNdITOeHOrnCV/YGTKjALHQZINcrIXljcCNtzOBA== X-Received: by 2002:a05:6e02:5a2:b0:346:390a:1ce6 with SMTP id k2-20020a056e0205a200b00346390a1ce6mr4553720ils.8.1689467870174; Sat, 15 Jul 2023 17:37:50 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id t3-20020a05663801e300b0042b52dc77e3sm3510512jaq.158.2023.07.15.17.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 38/81] buildman: Move counting of commits into a function Date: Sat, 15 Jul 2023 18:36:06 -0600 Message-ID: <20230716003718.231903-39-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230716003718.231903-1-sjg@chromium.org> References: <20230716003718.231903-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Move this code into a separate function to avoid a pylint warning in determine_series(). Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/control.py | 63 +++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 85c0c7b3a40d..3e6933cc05e7 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -159,6 +159,46 @@ def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch): return allow_missing +def count_commits(branch, count, col, git_dir): + """Could the number of commits in the branch/ranch being built + + Args: + branch (str): Name of branch to build, or None if none + count (int): Number of commits to build, or -1 for all + col (Terminal.Color): Color object to use + git_dir (str): Git directory to use, e.g. './.git' + + Returns: + tuple: + Number of commits being built + True if the 'branch' string contains a range rather than a simple + name + """ + has_range = branch and '..' in branch + if count == -1: + if not branch: + count = 1 + else: + if has_range: + count, msg = gitutil.count_commits_in_range(git_dir, branch) + else: + count, msg = gitutil.count_commits_in_branch(git_dir, branch) + if count is None: + sys.exit(col.build(col.RED, msg)) + elif count == 0: + sys.exit(col.build(col.RED, + f"Range '{branch}' has no commits")) + if msg: + print(col.build(col.YELLOW, msg)) + count += 1 # Build upstream commit also + + if not count: + msg = (f"No commits found to process in branch '{branch}': " + "set branch's upstream or use -c flag") + sys.exit(col.build(col.RED, msg)) + return count, has_range + + def determine_series(selected, col, git_dir, count, branch, work_in_output): """Determine the series which is to be built, if any @@ -189,28 +229,7 @@ def determine_series(selected, col, git_dir, count, branch, work_in_output): # Work out how many commits to build. We want to build everything on the # branch. We also build the upstream commit as a control so we can see # problems introduced by the first commit on the branch. - has_range = branch and '..' in branch - if count == -1: - if not branch: - count = 1 - else: - if has_range: - count, msg = gitutil.count_commits_in_range(git_dir, branch) - else: - count, msg = gitutil.count_commits_in_branch(git_dir, branch) - if count is None: - sys.exit(col.build(col.RED, msg)) - elif count == 0: - sys.exit(col.build(col.RED, - f"Range '{branch}' has no commits")) - if msg: - print(col.build(col.YELLOW, msg)) - count += 1 # Build upstream commit also - - if not count: - msg = (f"No commits found to process in branch '{branch}': " - "set branch's upstream or use -c flag") - sys.exit(col.build(col.RED, msg)) + count, has_range = count_commits(branch, count, col, git_dir) if work_in_output: if len(selected) != 1: sys.exit(col.build(col.RED, -- 2.41.0.455.g037347b96a-goog