]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
script/build-with-container: add --current-branch cli option
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 14 Feb 2025 16:24:06 +0000 (11:24 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 28 Feb 2025 20:16:35 +0000 (15:16 -0500)
Add a new --current-branch argument that lets the user supply a name for
the current branch. This allows the automatic tag generation to avoid
calling git - something useful if the tree is not using a git checkout
(like a tarball). It also allows you to pull a temporary branch in git
but ignore it and act like the temporary branch is the base branch.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/script/build-with-container.py

index f00eb39ce82d0a7af60323408e7c05d74a83c752..7b199eb42e6ef358dfbddca4970a695a557ad88f 100755 (executable)
@@ -286,10 +286,12 @@ class Context:
     def target_tag(self):
         if self.cli.tag:
             return self.cli.tag
-        try:
-            branch = _git_current_branch(self).replace("/", "-")
-        except subprocess.CalledProcessError:
-            branch = "UNKNOWN"
+        branch = self.cli.current_branch
+        if not branch:
+            try:
+                branch = _git_current_branch(self).replace("/", "-")
+            except subprocess.CalledProcessError:
+                branch = "UNKNOWN"
         return f"{branch}.{self.cli.distro}"
 
     @property
@@ -668,6 +670,10 @@ def parse_cli(build_step_names):
         "-t",
         help="Specify a container tag",
     )
+    parser.add_argument(
+        "--current-branch",
+        help="Manually specify the current branch name",
+    )
     parser.add_argument(
         "--image-repo",
         help="Specify a container image repository",