From fe559854e55d4d59ec7bffda89cfb144b3355630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Fri, 17 May 2024 13:00:45 +0200 Subject: [PATCH] Lint fixes --- backend_addon/hooks/post_gen_project.py | 4 ++-- backend_addon/tests/conftest.py | 1 + backend_addon/tests/test_cutter.py | 3 ++- project/hooks/post_gen_project.py | 9 +++++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend_addon/hooks/post_gen_project.py b/backend_addon/hooks/post_gen_project.py index 0950614..2dc1a67 100644 --- a/backend_addon/hooks/post_gen_project.py +++ b/backend_addon/hooks/post_gen_project.py @@ -1,12 +1,11 @@ """Post generation hook.""" -from copy import deepcopy from collections import OrderedDict +from copy import deepcopy from pathlib import Path from cookieplone.utils import console, files, git - context: OrderedDict = {{cookiecutter}} @@ -17,6 +16,7 @@ ] } + def handle_feature_headless(context: OrderedDict, output_dir: Path): package_namespace = context.get("__package_namespace") package_name = context.get("__package_name") diff --git a/backend_addon/tests/conftest.py b/backend_addon/tests/conftest.py index 12a2f29..c6eb0ca 100644 --- a/backend_addon/tests/conftest.py +++ b/backend_addon/tests/conftest.py @@ -102,6 +102,7 @@ def context_no_headless(context) -> dict: new_context["feature_headless"] = "0" return new_context + @pytest.fixture(scope="session") def context_no_git(context) -> dict: """Cookiecutter context without Git repository.""" diff --git a/backend_addon/tests/test_cutter.py b/backend_addon/tests/test_cutter.py index 246f8fc..f4c2123 100644 --- a/backend_addon/tests/test_cutter.py +++ b/backend_addon/tests/test_cutter.py @@ -1,8 +1,9 @@ """Test cookiecutter generation with all features enabled.""" +from pathlib import Path + import pytest -from pathlib import Path from .conftest import PKG_SRC_FEATURE_HEADLESS, PKG_SRC_FILES, ROOT_FILES diff --git a/project/hooks/post_gen_project.py b/project/hooks/post_gen_project.py index 86badaa..42ebbcd 100644 --- a/project/hooks/post_gen_project.py +++ b/project/hooks/post_gen_project.py @@ -95,6 +95,7 @@ def main(): """Final fixes.""" output_dir = Path().cwd() + initialize_git = bool(int(context.get("__project_git_initialize"))) # Cleanup / Git actions = [ [ @@ -109,8 +110,8 @@ def main(): ], [ handle_git_initialization, - "Remove GHA deployment files", - bool(int(context.get("__project_git_initialize"))), + "Initialize Git repository", + initialize_git, ], ] for func, title, enabled in actions: @@ -135,6 +136,10 @@ def main(): console.print(f" -> {title}") func(new_context, output_dir) + # Do a second run add newly created files + if initialize_git: + handle_git_initialization(context, output_dir) + msg = """ [bold blue]{{ cookiecutter.title }}[/bold blue]