Skip to content

Commit 791cdcf

Browse files
committed
fix: add a few workarounds trying to get POC branching going before refactoring
1 parent 85e2d50 commit 791cdcf

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

scripts/update-demo.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,23 @@ def update_demo(
3333
try:
3434
demo_name: str = get_demo_name(add_rust_extension=add_rust_extension)
3535
demo_path: Path = demos_cache_folder / demo_name
36-
develop_branch: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON_DEVELOP_BRANCH", "develop")
3736

3837
current_branch: str = get_current_branch()
3938
current_commit: str = get_current_commit()
4039

4140
_validate_is_feature_branch(branch=current_branch)
4241

43-
typer.secho(f"Updating demo project at {demo_path=}.", fg="yellow")
44-
with work_in(demo_path):
45-
require_clean_and_up_to_date_repo()
46-
git("checkout", develop_branch)
42+
last_update_commit: str = _get_last_demo_develop_cruft_update(demo_path=demo_path)
4743

48-
last_update_commit: str = get_last_cruft_update_commit(demo_path=demo_path)
49-
if not is_ancestor(last_update_commit, current_commit):
50-
raise ValueError(
51-
f"The last update commit '{last_update_commit}' is not an ancestor of the current commit "
52-
f"'{current_commit}'."
53-
)
44+
if not is_ancestor(last_update_commit, current_commit):
45+
raise ValueError(
46+
f"The last update commit '{last_update_commit}' is not an ancestor of the current commit "
47+
f"'{current_commit}'."
48+
)
5449

55-
if current_branch != develop_branch:
50+
typer.secho(f"Updating demo project at {demo_path=}.", fg="yellow")
51+
with work_in(demo_path):
52+
if current_branch != "develop":
5653
git("checkout", "-b", current_branch)
5754

5855
uv("python", "pin", min_python_version)
@@ -77,6 +74,20 @@ def update_demo(
7774
sys.exit(1)
7875

7976

77+
def _get_last_demo_develop_cruft_update(demo_path: Path) -> str:
78+
"""Gets the last cruft update commit for the demo project's develop branch."""
79+
_prep_demo_develop(demo_path=demo_path)
80+
last_update_commit: str = get_last_cruft_update_commit(demo_path=demo_path)
81+
return last_update_commit
82+
83+
84+
def _prep_demo_develop(demo_path: Path) -> None:
85+
"""Checks out the demo development branch and validates it is up to date."""
86+
with work_in(demo_path):
87+
require_clean_and_up_to_date_repo()
88+
git("checkout", "develop")
89+
90+
8091
def _validate_is_feature_branch(branch: str) -> None:
8192
"""Validates that the cookiecutter has a feature branch checked out."""
8293
if not branch.startswith("feature/"):

0 commit comments

Comments
 (0)