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 2936FC001DC for ; Wed, 19 Jul 2023 23:57:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D5ABF86857; Thu, 20 Jul 2023 01:51:41 +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="Y/2gKwJS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1C972867DF; Thu, 20 Jul 2023 01:50:37 +0200 (CEST) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 AB18E867E2 for ; Thu, 20 Jul 2023 01:50:30 +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-xd32.google.com with SMTP id ca18e2360f4ac-78360b822abso8389539f.2 for ; Wed, 19 Jul 2023 16:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810629; x=1690415429; 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=WOW8IKHQFv43/ZzfNYB92MD0oHlCOTaQvfAWlzrPmPM=; b=Y/2gKwJSez5z5bJ6vc39c8dhjp13Wjs9RaP6YiRoWo4t9fEzL/FIXFRbgsK5Ve7rd2 WyZo05ruTzYwYDCfhSHvHzrRX9mhWQmo04qJ9UmV4hT8daqv6AF19kkZDuQ8TLxG54K+ D1o8Y237rYtUlM4iBV2D0CprgaKhkGPjzMo0I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810629; x=1690415429; 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=WOW8IKHQFv43/ZzfNYB92MD0oHlCOTaQvfAWlzrPmPM=; b=G4HM9xtZimX5tcYJohdsshRVOSRopuBRv80DTuhGr+mP2uGVjDNz6XCJ7Bt354Bgur svWVSq8L/FcIjJptVkBnijaQjHTUUq/WIWYg453oYmpynl4FhhpG8Q/IhKBuqOrdSPk5 i+LpK7FPDvOIwPymsSIm5uGATmPn/Dru70hp+y3KRSBcBZLtdku3s0Tfh4yzOh1YXXkF /RYKFOfxswy1EdNKab3l+mqmrnne8/6D56tZ8O5Qidy06nXcni3Uxd/23Yu/PPgV9BU1 Fnnl6qXGuZDfEQKieJX5X1IrqJh07nj9OlYLXXwSGV73G2NktjivSla+bnP2inKnlXuP AiPA== X-Gm-Message-State: ABy/qLZLBvjtefqHaWwWW5u5HciI+EKejw3vx/A3/S60CxSl6lYvHpkq +9GNnEq8rQ9cTrFMmHnNVL9AAv2FwQdGwUl7NpI= X-Google-Smtp-Source: APBJJlE2YHnaDAps0x7g/T+NP7Jx4iQUhGpywK0VUYTXOsq/iTIRUtV2PZpny7Czgmh1i68wAR6JBg== X-Received: by 2002:a6b:7f48:0:b0:77e:3d2f:d1f4 with SMTP id m8-20020a6b7f48000000b0077e3d2fd1f4mr3790435ioq.15.1689810629270; Wed, 19 Jul 2023 16:50:29 -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 ed16-20020a056638291000b0042bb1779c18sm1551779jab.151.2023.07.19.16.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 40/83] buildman: Move counting of commits into a function Date: Wed, 19 Jul 2023 17:48:48 -0600 Message-ID: <20230719234953.796101-41-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230719234953.796101-1-sjg@chromium.org> References: <20230719234953.796101-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.487.g6d72f3e995-goog