Skip to content

Commit 58f3520

Browse files
committed
fix: update names throughout nox session and file along with fix update-demo not creating branches and some env var issues
1 parent 3483e9e commit 58f3520

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,22 @@
3535
if DEFAULT_ENV_FILE.exists():
3636
load_dotenv(DEFAULT_ENV_FILE)
3737

38-
APP_AUTHOR: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON_APP_AUTHOR", "robust-python")
39-
COOKIECUTTER_ROBUST_PYTHON_CACHE_FOLDER: Path = Path(
38+
APP_AUTHOR: str = os.getenv("COOKIECUTTER_ROBUST_PYTHON__APP_AUTHOR", "robust-python")
39+
COOKIECUTTER_ROBUST_PYTHON__CACHE_FOLDER: Path = Path(
4040
platformdirs.user_cache_path(
4141
appname="cookiecutter-robust-python",
4242
appauthor=APP_AUTHOR,
4343
ensure_exists=True,
4444
)
4545
).resolve()
4646

47-
DEFAULT_DEMOS_CACHE_FOLDER = COOKIECUTTER_ROBUST_PYTHON_CACHE_FOLDER / "project_demos"
47+
DEFAULT_DEMOS_CACHE_FOLDER = COOKIECUTTER_ROBUST_PYTHON__CACHE_FOLDER / "project_demos"
4848
DEMOS_CACHE_FOLDER: Path = Path(
4949
os.getenv(
5050
"COOKIECUTTER_ROBUST_PYTHON__DEMOS_CACHE_FOLDER", default=DEFAULT_DEMOS_CACHE_FOLDER
5151
)
5252
).resolve()
5353
DEFAULT_DEMO_NAME: str = "robust-python-demo"
54-
DEMO_ROOT_FOLDER: Path = DEMOS_CACHE_FOLDER / DEFAULT_DEMO_NAME
5554

5655
GENERATE_DEMO_SCRIPT: Path = SCRIPTS_FOLDER / "generate-demo.py"
5756
GENERATE_DEMO_OPTIONS: tuple[str, ...] = (

scripts/update-demo.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def update_demo(
5151

5252
if branch_override is not None:
5353
typer.secho(f"Overriding current branch name for demo reference. Using '{branch_override}' instead.")
54-
current_branch: str = branch_override
54+
desired_branch_name: str = branch_override
5555
else:
56-
current_branch: str = get_current_branch()
56+
desired_branch_name: str = get_current_branch()
5757
template_commit: str = get_current_commit()
5858

59-
_validate_template_main_not_checked_out(branch=current_branch)
59+
_validate_template_main_not_checked_out(branch=desired_branch_name)
6060
require_clean_and_up_to_date_demo_repo(demo_path=demo_path)
61-
_checkout_demo_develop_or_existing_branch(demo_path=demo_path, branch=current_branch)
61+
_checkout_demo_develop_or_existing_branch(demo_path=demo_path, branch=desired_branch_name)
6262
last_update_commit: str = get_last_cruft_update_commit(demo_path=demo_path)
6363

6464
if not is_ancestor(last_update_commit, template_commit):
@@ -69,6 +69,9 @@ def update_demo(
6969

7070
typer.secho(f"Updating demo project at {demo_path=}.", fg="yellow")
7171
with work_in(demo_path):
72+
if get_current_branch() != desired_branch_name:
73+
git("checkout", "-b", desired_branch_name, DEMO.develop_branch)
74+
7275
uv("python", "pin", min_python_version)
7376
uv("python", "install", min_python_version)
7477
cruft.update(
@@ -84,9 +87,9 @@ def update_demo(
8487
uv("lock")
8588
git("add", ".")
8689
git("commit", "-m", f"chore: {last_update_commit} -> {template_commit}", "--no-verify")
87-
git("push", "-u", "origin", current_branch)
88-
if current_branch != "develop":
89-
_create_demo_pr(demo_path=demo_path, branch=current_branch, commit_start=last_update_commit)
90+
git("push", "-u", "origin", desired_branch_name)
91+
if desired_branch_name != "develop":
92+
_create_demo_pr(demo_path=demo_path, branch=desired_branch_name, commit_start=last_update_commit)
9093

9194

9295
def _checkout_demo_develop_or_existing_branch(demo_path: Path, branch: str) -> None:

0 commit comments

Comments
 (0)