From 5e81f758ef66f333543203e6ceec4ef9e1cbcb8b Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 14 Feb 2025 11:37:04 -0500 Subject: [PATCH] script/build-with-container: add --base-branch cli option Add a command line option --base-branch that allows the user to supply a custom base branch name. git doesn't make determining this easy so we always assume a base branch of 'main' by default - but this option lets one change that. Signed-off-by: John Mulligan (cherry picked from commit ff34bf7241f1a1072f74494cc8f50156e0076019) --- src/script/build-with-container.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/script/build-with-container.py b/src/script/build-with-container.py index 7b199eb42e6..d7ec7c0ad12 100755 --- a/src/script/build-with-container.py +++ b/src/script/build-with-container.py @@ -294,6 +294,15 @@ class Context: branch = "UNKNOWN" return f"{branch}.{self.cli.distro}" + def base_branch(self): + # because git truly is the *stupid* content tracker there's not a + # simple way to detect base branch. In BWC the base branch is really + # only here for an optional 2nd level of customization in the build + # container bootstrap we default to `main` even when that's not true. + # One can explicltly set the base branch on the command line to invoke + # customizations (that don't yet exist) or invalidate image caching. + return self.cli.base_branch or 'main' + @property def from_image(self): if self.cli.base_image: @@ -401,6 +410,7 @@ def build_container(ctx): "-t", ctx.image_name, f"--build-arg=JENKINS_HOME={ctx.cli.homedir}", + f"--build-arg=CEPH_BASE_BRANCH={ctx.base_branch()}", ] if ctx.cli.distro: cmd.append(f"--build-arg=DISTRO={ctx.from_image}") @@ -670,6 +680,10 @@ def parse_cli(build_step_names): "-t", help="Specify a container tag", ) + parser.add_argument( + "--base-branch", + help="Specify a base branch name", + ) parser.add_argument( "--current-branch", help="Manually specify the current branch name", -- 2.39.5