]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
script/build-with-container: add --base-branch cli option
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 14 Feb 2025 16:37:04 +0000 (11:37 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 28 Feb 2025 20:16:35 +0000 (15:16 -0500)
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 <jmulligan@redhat.com>
src/script/build-with-container.py

index 7b199eb42e6ef358dfbddca4970a695a557ad88f..d7ec7c0ad1254f6af2520ebe4284124ce2b49cd7 100755 (executable)
@@ -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",