Skip to content

Commit

Permalink
fix: make A/B tests work in release branches
Browse files Browse the repository at this point in the history
If we receive a branch, qualify it with `origin` before handing it to
git.

Signed-off-by: Pablo Barbáchano <[email protected]>
  • Loading branch information
pb8o authored and wearyzen committed Dec 20, 2023
1 parent a43fddf commit b49d9fa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/framework/ab_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,21 @@ def temporary_checkout(revision: str):
happen along the way.
"""
with TemporaryDirectory() as tmp_dir:
basename = Path(tmp_dir).name
ret, _, _ = utils.run_cmd(
f"git cat-file -t {revision}", ignore_return_code=True
)
if ret != 0:
# git didn't recognize this object, so maybe it is a branch; qualify it
revision = f"origin/{revision}"
# make a temp branch for that commit so we can directly check it out
utils.run_cmd(f"git branch {basename} {revision}")
# `git clone` can take a path instead of an URL, which causes it to create a copy of the
# repository at the given path. However, that path needs to point to the root of a repository,
# it cannot be some arbitrary subdirectory. Therefore:
_, git_root, _ = utils.run_cmd("git rev-parse --show-toplevel")
# split off the '\n' at the end of the stdout
utils.run_cmd(f"git clone {git_root.strip()} {tmp_dir}")

with chdir(tmp_dir):
utils.run_cmd(f"git checkout {revision}")

utils.run_cmd(f"git clone -b {basename} {git_root.strip()} {tmp_dir}")
yield Path(tmp_dir)

# If we compiled firecracker inside the checkout, python's recursive shutil.rmdir will
Expand Down

0 comments on commit b49d9fa

Please sign in to comment.