Skip to content

Commit 7969d23

Browse files
committed
feat: add default option to use current branch and add placeholder default for cache folder for the time until it gets moved to config passthrough later
1 parent bda6c83 commit 7969d23

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/merge-demo-feature.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
import subprocess
1111
from pathlib import Path
1212
from typing import Annotated
13+
from typing import Optional
1314

1415
import typer
1516
from cookiecutter.utils import work_in
1617

1718
from util import DEMO
1819
from util import FolderOption
20+
from util import get_current_branch
1921
from util import get_demo_name
2022
from util import gh
2123

@@ -25,13 +27,18 @@
2527

2628
@cli.callback(invoke_without_command=True)
2729
def merge_demo_feature(
28-
branch: str,
29-
demos_cache_folder: Annotated[Path, FolderOption("--demos-cache-folder", "-c")],
30+
branch: Optional[str] = None,
31+
demos_cache_folder: Annotated[Path, FolderOption("--demos-cache-folder", "-c")] = None,
3032
add_rust_extension: Annotated[bool, typer.Option("--add-rust-extension", "-r")] = False
3133
) -> None:
3234
"""Searches for the given demo feature branch's PR and merges it if ready."""
3335
demo_name: str = get_demo_name(add_rust_extension=add_rust_extension)
36+
if demos_cache_folder is None:
37+
raise ValueError("Failed to provide a demos cache folder.")
38+
3439
demo_path: Path = demos_cache_folder / demo_name
40+
branch: str = branch if branch is not None else get_current_branch()
41+
3542
with work_in(demo_path):
3643
pr_number_query: subprocess.CompletedProcess = gh(
3744
"pr", "list", "--head", branch, "--base", DEMO.develop_branch, "--json", "number", "--jq", "'.[0].number'"

0 commit comments

Comments
 (0)