Skip to content

Commit d84f96b

Browse files
committed
additional check for existence of branches
1 parent 005e898 commit d84f96b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

commit0/harness/run_pytest_ids.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ def main(
8484
if branch == "reference":
8585
commit_id = example["reference_commit"]
8686
else:
87-
if branch not in local_repo.branches:
88-
raise Exception(f"Branch {branch} does not exist.")
89-
local_branch = local_repo.branches[branch]
90-
commit_id = local_branch.commit.hexsha
87+
try:
88+
local_repo.git.checkout(branch)
89+
local_branch = local_repo.branches[branch]
90+
commit_id = local_branch.commit.hexsha
91+
except Exception as e:
92+
raise Exception(f"Problem checking out branch {branch}.\n{e}")
9193
patch = generate_patch_between_commits(
9294
local_repo, example["base_commit"], commit_id
9395
)

0 commit comments

Comments
 (0)