@@ -43,49 +43,44 @@ def update_demo(
4343 max_python_version : Annotated [str , typer .Option ("--max-python-version" )] = "3.14"
4444) -> None :
4545 """Runs precommit in a generated project and matches the template to the results."""
46- try :
47- demo_name : str = get_demo_name (add_rust_extension = add_rust_extension )
48- demo_path : Path = demos_cache_folder / demo_name
49-
50- current_branch : str = get_current_branch ()
51- template_commit : str = get_current_commit ()
52-
53- _validate_template_main_not_checked_out (branch = current_branch )
54- require_clean_and_up_to_date_repo (demo_path = demo_path )
55- _checkout_demo_develop_or_existing_branch (demo_path = demo_path , branch = current_branch )
56- last_update_commit : str = get_last_cruft_update_commit (demo_path = demo_path )
57-
58- if not is_ancestor (last_update_commit , template_commit ):
59- raise ValueError (
60- f"The last update commit '{ last_update_commit } ' is not an ancestor of the current commit "
61- f"'{ template_commit } '."
62- )
63-
64- typer .secho (f"Updating demo project at { demo_path = } ." , fg = "yellow" )
65- with work_in (demo_path ):
66- if current_branch != "develop" :
67- git ("checkout" , "-b" , current_branch )
68-
69- uv ("python" , "pin" , min_python_version )
70- uv ("python" , "install" , min_python_version )
71- cruft .update (
72- project_dir = demo_path ,
73- template_path = REPO_FOLDER ,
74- extra_context = {
75- "project_name" : demo_name ,
76- "add_rust_extension" : add_rust_extension ,
77- "min_python_version" : min_python_version ,
78- "max_python_version" : max_python_version
79- },
80- )
81- uv ("lock" )
82- git ("add" , "." )
83- git ("commit" , "-m" , f"chore: { last_update_commit } -> { template_commit } " , "--no-verify" )
84- git ("push" , "-u" , "origin" , current_branch )
85-
86- except Exception as error :
87- typer .secho (f"error: { error } " , fg = "red" )
88- sys .exit (1 )
46+ demo_name : str = get_demo_name (add_rust_extension = add_rust_extension )
47+ demo_path : Path = demos_cache_folder / demo_name
48+
49+ current_branch : str = get_current_branch ()
50+ template_commit : str = get_current_commit ()
51+
52+ _validate_template_main_not_checked_out (branch = current_branch )
53+ require_clean_and_up_to_date_repo (demo_path = demo_path )
54+ _checkout_demo_develop_or_existing_branch (demo_path = demo_path , branch = current_branch )
55+ last_update_commit : str = get_last_cruft_update_commit (demo_path = demo_path )
56+
57+ if not is_ancestor (last_update_commit , template_commit ):
58+ raise ValueError (
59+ f"The last update commit '{ last_update_commit } ' is not an ancestor of the current commit "
60+ f"'{ template_commit } '."
61+ )
62+
63+ typer .secho (f"Updating demo project at { demo_path = } ." , fg = "yellow" )
64+ with work_in (demo_path ):
65+ if current_branch != "develop" :
66+ git ("checkout" , "-b" , current_branch )
67+
68+ uv ("python" , "pin" , min_python_version )
69+ uv ("python" , "install" , min_python_version )
70+ cruft .update (
71+ project_dir = demo_path ,
72+ template_path = REPO_FOLDER ,
73+ extra_context = {
74+ "project_name" : demo_name ,
75+ "add_rust_extension" : add_rust_extension ,
76+ "min_python_version" : min_python_version ,
77+ "max_python_version" : max_python_version
78+ },
79+ )
80+ uv ("lock" )
81+ git ("add" , "." )
82+ git ("commit" , "-m" , f"chore: { last_update_commit } -> { template_commit } " , "--no-verify" )
83+ git ("push" , "-u" , "origin" , current_branch )
8984
9085
9186def _checkout_demo_develop_or_existing_branch (demo_path : Path , branch : str ) -> None :
0 commit comments