fix(update): conventional commit message with the template version
This commit is contained in:
+12
-1
@@ -95,6 +95,17 @@ def git_dirty() -> bool:
|
|||||||
return bool(result.stdout.strip())
|
return bool(result.stdout.strip())
|
||||||
|
|
||||||
|
|
||||||
|
def update_message(answers: Path) -> str:
|
||||||
|
"""Conventional commit for a template update, with the version it moved to."""
|
||||||
|
ref = ""
|
||||||
|
for line in answers.read_text(encoding="utf-8").splitlines():
|
||||||
|
if line.startswith("_commit:"):
|
||||||
|
ref = line.split(":", 1)[1].strip().strip("'\"")
|
||||||
|
break
|
||||||
|
scope = answers.stem
|
||||||
|
return f"chore({scope}): update template to {ref}" if ref else f"chore({scope}): update template"
|
||||||
|
|
||||||
|
|
||||||
def update(args: argparse.Namespace) -> None:
|
def update(args: argparse.Namespace) -> None:
|
||||||
answers = sorted(Path(".copier").glob("*.yml"))
|
answers = sorted(Path(".copier").glob("*.yml"))
|
||||||
if args.parts:
|
if args.parts:
|
||||||
@@ -108,7 +119,7 @@ def update(args: argparse.Namespace) -> None:
|
|||||||
skip_answered=not args.ask, defaults=args.defaults, vcs_ref=REF)
|
skip_answered=not args.ask, defaults=args.defaults, vcs_ref=REF)
|
||||||
if git_dirty():
|
if git_dirty():
|
||||||
subprocess.run(["git", "add", "-A"], check=True)
|
subprocess.run(["git", "add", "-A"], check=True)
|
||||||
subprocess.run(["git", "commit", "-qm", f"Update {file.stem} template"], check=True)
|
subprocess.run(["git", "commit", "-qm", update_message(file)], check=True)
|
||||||
print(f"committed {file.stem} update")
|
print(f"committed {file.stem} update")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user