Deploy hooks
This commit is contained in:
@@ -90,15 +90,26 @@ def new(args: argparse.Namespace) -> None:
|
||||
subprocess.run(["make", "env"], cwd=dest, check=True)
|
||||
|
||||
|
||||
def git_dirty() -> bool:
|
||||
result = subprocess.run(["git", "status", "--porcelain"], capture_output=True, text=True, check=False)
|
||||
return bool(result.stdout.strip())
|
||||
|
||||
|
||||
def update(args: argparse.Namespace) -> None:
|
||||
answers = sorted(Path(".copier").glob("*.yml"))
|
||||
if args.parts:
|
||||
answers = [Path(".copier") / f"{p}.yml" for p in args.parts]
|
||||
if not answers:
|
||||
sys.exit("no .copier/*.yml here")
|
||||
if git_dirty():
|
||||
sys.exit("working tree is dirty, commit or stash first")
|
||||
for file in answers:
|
||||
run_update(".", answers_file=str(file), unsafe=True, overwrite=True,
|
||||
skip_answered=not args.ask, defaults=args.defaults, vcs_ref=REF)
|
||||
if git_dirty():
|
||||
subprocess.run(["git", "add", "-A"], check=True)
|
||||
subprocess.run(["git", "commit", "-qm", f"Update {file.stem} template"], check=True)
|
||||
print(f"committed {file.stem} update")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Reference in New Issue
Block a user