From: John Mulligan Date: Fri, 14 Feb 2025 16:24:06 +0000 (-0500) Subject: script/build-with-container: add --current-branch cli option X-Git-Tag: v18.2.5~23^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=98be912957232484fcd86e1bcd7ffbab36d36e31;p=ceph.git script/build-with-container: add --current-branch cli option 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 (cherry picked from commit c1713c5bc37b7e31bd84555066c06a72bb0f025b) --- diff --git a/src/script/build-with-container.py b/src/script/build-with-container.py index f00eb39ce82d0..7b199eb42e6ef 100755 --- a/src/script/build-with-container.py +++ b/src/script/build-with-container.py @@ -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",