Skip to content

Commit

Permalink
Avoid the double call to run_subprocess* in is_branch()
Browse files Browse the repository at this point in the history
  • Loading branch information
favilo committed Jan 31, 2024
1 parent f9a8a29 commit 21caafa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions esrally/utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ def is_working_copy(src):
@probed
def is_branch(src_dir, identifier):
show_ref_cmd = f"git -C {src_dir} show-ref {identifier}"
completed_process = process.run_subprocess(show_ref_cmd)

# if we get an non-zero exit code, we know that the identifier is not a branch (local or remote)
if not process.exit_status_as_bool(lambda: process.run_subprocess_with_logging(show_ref_cmd)):
if not process.exit_status_as_bool(lambda: completed_process.returncode):
return False

# it's possible the identifier could be a tag, so we explicitly check that here
ref = process.run_subprocess_with_output(show_ref_cmd)
ref = completed_process.stdout.decode("utf-8").split("\n")
if "refs/tags" in ref[0]:
return False

Expand Down

0 comments on commit 21caafa

Please sign in to comment.