1- import sys
21from pathlib import Path
32from typing import Annotated
43
1110from util import in_new_demo
1211
1312
13+ # These still may need linted, but retrocookie shouldn't be used on them
14+ IGNORED_FILES : list [str ] = [
15+ "{{cookiecutter.project_name}}/pyproject.toml" ,
16+ "{{cookiecutter.project_name}}/uv.lock" ,
17+ ""
18+ ]
19+
20+
1421cli : typer .Typer = typer .Typer ()
1522
1623
@@ -21,20 +28,21 @@ def lint_from_demo(
2128 no_cache : Annotated [bool , typer .Option ("--no-cache" , "-n" )] = False
2229) -> None :
2330 """Runs precommit in a generated project and matches the template to the results."""
24- try :
25- with in_new_demo (
26- demos_cache_folder = demos_cache_folder ,
27- add_rust_extension = add_rust_extension ,
28- no_cache = no_cache
29- ) as demo_path :
30- pre_commit .main .main (["run" , "--all-files" , "--hook-stage=manual" , "--show-diff-on-failure" ])
31- try :
32- retrocookie (instance_path = demo_path , commits = ["HEAD" ])
33- finally :
34- git ("checkout" , "HEAD" , "--" , "{{cookiecutter.project_name}}/pyproject.toml" )
35- except Exception as error :
36- typer .secho (f"error: { error } " , fg = "red" )
37- sys .exit (1 )
31+ with in_new_demo (
32+ demos_cache_folder = demos_cache_folder ,
33+ add_rust_extension = add_rust_extension ,
34+ no_cache = no_cache
35+ ) as demo_path :
36+ git ("status" , "--porcelain" )
37+ git ("branch" , "-D" , "temp/lint-from-demo" , ignore_error = True )
38+ git ("checkout" , "-b" , "temp/lint-from-demo" , "develop" )
39+ pre_commit .main .main (["run" , "--all-files" , "--hook-stage=manual" , "--show-diff-on-failure" ])
40+
41+ for path in IGNORED_FILES :
42+ git ("checkout" , "HEAD" , "--" , path )
43+ git ("add" , "." )
44+ git ("commit" , "-m" , "meta: lint-from-demo" , "--no-verify" )
45+ retrocookie (instance_path = demo_path , commits = ["HEAD" ], branch = "temp/lint-from-demo" )
3846
3947
4048if __name__ == '__main__' :
0 commit comments