From e680cd24499b97f352155a7fa85a98b61bff7a5d Mon Sep 17 00:00:00 2001 From: MatDagommer Date: Wed, 31 Dec 2025 10:25:02 +0100 Subject: [PATCH 1/2] =?UTF-8?q?feat(project-cli)=F0=9F=8E=89:=20Initialize?= =?UTF-8?q?=20git=20repository=20after=20project=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change project init command to initialize a git repository in the newly created project directory. - Add loguru logger to provide feedback on git initialization success. - Handle exceptions during git initialization and print a warning if it fails. --- pyml_cli/cli/project.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pyml_cli/cli/project.py b/pyml_cli/cli/project.py index 7408705..674759d 100644 --- a/pyml_cli/cli/project.py +++ b/pyml_cli/cli/project.py @@ -1,8 +1,11 @@ """Project initialization CLI.""" +import os from pathlib import Path from cookiecutter.main import cookiecutter +from loguru import logger +from sh import git from typer import Typer app = Typer() @@ -13,4 +16,13 @@ @app.command() def init(): """Initialize project from template.""" - cookiecutter(str(PROJECT_TEMPLATE_DIR.resolve())) + output_dir = cookiecutter(str(PROJECT_TEMPLATE_DIR.resolve())) + + if output_dir: + project_path = Path(output_dir) + try: + os.chdir(project_path) + git("init") + logger.info(f"✓ Initialized git repository in {project_path}") + except Exception as e: + print(f"⚠ Git initialization failed: {e} - skipping git initialization") From 47849e57327731cf640c36b03a9572ff7146a7ea Mon Sep 17 00:00:00 2001 From: MatDagommer Date: Wed, 31 Dec 2025 10:25:40 +0100 Subject: [PATCH 2/2] =?UTF-8?q?chore(project)=F0=9F=8C=B1:=20set=20default?= =?UTF-8?q?=20git=20branch=20to=20main=20during=20project=20initialization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update git initialization command to use 'main' as the default branch instead of the default git branch. --- pyml_cli/cli/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyml_cli/cli/project.py b/pyml_cli/cli/project.py index 674759d..b8ba850 100644 --- a/pyml_cli/cli/project.py +++ b/pyml_cli/cli/project.py @@ -22,7 +22,7 @@ def init(): project_path = Path(output_dir) try: os.chdir(project_path) - git("init") + git("init", "-b", "main") logger.info(f"✓ Initialized git repository in {project_path}") except Exception as e: print(f"⚠ Git initialization failed: {e} - skipping git initialization")