Skip to content

Commit 6b02056

Browse files
committed
refactor: move constants to module level in places
1 parent 9816734 commit 6b02056

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

scripts/release-demo.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# /// script
2+
# requires-python = ">=3.10"
3+
# dependencies = [
4+
# cookiecutter,
5+
# cruft,
6+
# typer,
7+
# ]
8+
# ///
9+
from pathlib import Path
10+
from typing import Annotated
11+
12+
import typer
13+
from cookiecutter.utils import work_in
14+
15+
from util import get_demo_name
16+
from util import git
17+
from util import is_ancestor
18+
from util import uv
19+
from util import validate_is_synced_ancestor
20+
from util import FolderOption
21+
22+
23+
cli: typer.Typer = typer.Typer()
24+
25+
26+
@cli.callback(invoke_without_command=True)
27+
def release_demo(
28+
demos_cache_folder: Annotated[Path, FolderOption("--demos-cache-folder", "-c")],
29+
min_python_version: Annotated[str, typer.Option("--min-python-version")],
30+
max_python_version: Annotated[str, typer.Option("--max-python-version")],
31+
add_rust_extension: Annotated[bool, typer.Option("--add-rust-extension", "-r")] = False
32+
) -> None:
33+
"""Creates a release of the demo's current develop branch if changes exist."""
34+
demo_name: str = get_demo_name(add_rust_extension=add_rust_extension)
35+
demo_path: Path = demos_cache_folder / demo_name
36+
37+
38+
39+
40+
def _validate_demo_develop_up_to_date(demo_path: Path) -> None:
41+
"""Ensures the demo's develop branch is up to date."""
42+
with work_in(demo_path):
43+
validate_is_synced_ancestor(ancestor=)
44+
45+
46+
47+
48+
49+
50+

scripts/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def _load_env() -> None:
6060
)
6161

6262

63+
MAIN_BRANCH: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON_MAIN_BRANCH", "main")
64+
DEVELOP_BRANCH: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON_DEVELOP_BRANCH", "develop")
65+
66+
6367
def remove_readonly(func: Callable[[str], Any], path: str, _: Any) -> None:
6468
"""Clears the readonly bit and attempts to call the provided function.
6569
@@ -98,12 +102,9 @@ def run_command(command: str, *args: str, ignore_error: bool = False) -> Optiona
98102

99103
def require_clean_and_up_to_date_repo() -> None:
100104
"""Checks if the repo is clean and up to date with any important branches."""
101-
main_branch: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON_MAIN_BRANCH", "main")
102-
develop_branch: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON_DEVELOP_BRANCH", "develop")
103-
104105
git("fetch")
105106
git("status", "--porcelain")
106-
validate_is_synced_ancestor(ancestor=main_branch, descendent=develop_branch)
107+
validate_is_synced_ancestor(ancestor=MAIN_BRANCH, descendent=DEVELOP_BRANCH)
107108

108109

109110
def validate_is_synced_ancestor(ancestor: str, descendent: str) -> None:

0 commit comments

Comments
 (0)