Skip to content

Commit 0ff3bcd

Browse files
committed
fix: add a few workarounds trying to get POC branching going before refactoring
1 parent f99c0b8 commit 0ff3bcd

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
@@ -30,26 +30,23 @@ def update_demo(
3030
try:
3131
demo_name: str = get_demo_name(add_rust_extension=add_rust_extension)
3232
demo_path: Path = demos_cache_folder / demo_name
33-
develop_branch: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON_DEVELOP_BRANCH", "develop")
3433

3534
current_branch: str = get_current_branch()
3635
current_commit: str = get_current_commit()
3736

3837
_validate_is_feature_branch(branch=current_branch)
3938

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

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

52-
if current_branch != develop_branch:
47+
typer.secho(f"Updating demo project at {demo_path=}.", fg="yellow")
48+
with work_in(demo_path):
49+
if current_branch != "develop":
5350
git("checkout", "-b", current_branch)
5451

5552
cruft.update(
@@ -66,6 +63,20 @@ def update_demo(
6663
sys.exit(1)
6764

6865

66+
def _get_last_demo_develop_cruft_update(demo_path: Path) -> str:
67+
"""Gets the last cruft update commit for the demo project's develop branch."""
68+
_prep_demo_develop(demo_path=demo_path)
69+
last_update_commit: str = get_last_cruft_update_commit(demo_path=demo_path)
70+
return last_update_commit
71+
72+
73+
def _prep_demo_develop(demo_path: Path) -> None:
74+
"""Checks out the demo development branch and validates it is up to date."""
75+
with work_in(demo_path):
76+
require_clean_and_up_to_date_repo()
77+
git("checkout", "develop")
78+
79+
6980
def _validate_is_feature_branch(branch: str) -> None:
7081
"""Validates that the cookiecutter has a feature branch checked out."""
7182
if not branch.startswith("feature/"):

0 commit comments

Comments
 (0)