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)
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)