|
10 | 10 | import commit0.harness.lint |
11 | 11 | import commit0.harness.save |
12 | 12 | from commit0.harness.constants import SPLIT, SPLIT_ALL |
| 13 | +from commit0.harness.utils import get_active_branch |
13 | 14 | import subprocess |
14 | 15 | import yaml |
15 | 16 | import os |
@@ -245,14 +246,11 @@ def test( |
245 | 246 |
|
246 | 247 | commit0_config = read_commit0_dot_file(commit0_dot_file_path) |
247 | 248 |
|
248 | | - if not branch and not reference: |
249 | | - raise typer.BadParameter( |
250 | | - f"Invalid {highlight('BRANCH', Colors.RED)}. Either --reference or provide a branch name.", |
251 | | - param_hint="BRANCH", |
252 | | - ) |
253 | 249 | if reference: |
254 | 250 | branch = "reference" |
255 | | - assert branch is not None, "branch is not specified" |
| 251 | + if branch is None and not reference: |
| 252 | + git_path = os.path.join(commit0_config["base_dir"], repo_or_repo_path.split("/")[-1]) |
| 253 | + branch = get_active_branch(git_path) |
256 | 254 |
|
257 | 255 | if verbose == 2: |
258 | 256 | typer.echo(f"Running tests for repository: {repo_or_repo_path}") |
@@ -294,14 +292,8 @@ def evaluate( |
294 | 292 | ) -> None: |
295 | 293 | """Evaluate Commit0 split you choose in Setup Stage.""" |
296 | 294 | check_commit0_path() |
297 | | - if not branch and not reference: |
298 | | - raise typer.BadParameter( |
299 | | - f"Invalid {highlight('BRANCH', Colors.RED)}. Either --reference or provide a branch name", |
300 | | - param_hint="BRANCH", |
301 | | - ) |
302 | 295 | if reference: |
303 | 296 | branch = "reference" |
304 | | - assert branch is not None, "branch is not specified" |
305 | 297 |
|
306 | 298 | commit0_config = read_commit0_dot_file(commit0_dot_file_path) |
307 | 299 | check_valid(commit0_config["repo_split"], SPLIT) |
|
0 commit comments