]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
script/build-with-container: cache git branch result
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 21 Mar 2025 18:28:25 +0000 (14:28 -0400)
committerDavid Galloway <david.galloway@ibm.com>
Thu, 31 Jul 2025 21:55:18 +0000 (17:55 -0400)
Cache the branch we got from the git command as it is highly unlikely
to change during the script execution and if it does -- we mostly don't
care anyway.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit e562aa086197c2950c9ebb9f8f112e88e1e6e666)

src/script/build-with-container.py

index 77a49182404b4a0b007e6093b724c812e8db64c0..d22e20b1e0494c0893e66272795ff053a45a9e53 100755 (executable)
@@ -231,6 +231,9 @@ def _git_command(ctx, args):
     return cmd
 
 
+# Assume that the git version will not be changing after the 1st time
+# the command is run.
+@functools.cache
 def _git_current_branch(ctx):
     cmd = _git_command(ctx, ["rev-parse", "--abbrev-ref", "HEAD"])
     res = _run(cmd, check=True, capture_output=True)