tests: export target_branch="${branch}"

Avoid running "git remote show origin" repeatedly when common.bash
gets sourced multiple times and target_branch was not specified by
the caller.

Repeated "git remote show origin" calls inflicted the additional
overhead of authenticating and communicating with the remote git
repository.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
Dan Mihai
2026-05-16 00:42:29 +00:00
parent 0f3df5d1e4
commit b85fc8ed13

View File

@@ -32,6 +32,9 @@ RUNTIME="${RUNTIME:-containerd-shim-kata-v2}"
export branch="${target_branch:-"$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')"}"
# Export target_branch to avoid hitting the remote repository again when this script gets loaded again.
export target_branch="${branch}"
function die() {
local msg="$*"