From 9b69002581f0097341a95a1fc7add8ca2c898d42 Mon Sep 17 00:00:00 2001 From: Adam <123621952+morington@users.noreply.github.com> Date: Sun, 30 Jun 2024 23:21:28 +0300 Subject: [PATCH] Bug fix. If we specified a file with a dot, it is automatically added to .gitignore --- confhub/builder.py | 4 ++++ confhub/commands.py | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/confhub/builder.py b/confhub/builder.py index 7468c6d..0bb2fad 100644 --- a/confhub/builder.py +++ b/confhub/builder.py @@ -6,6 +6,7 @@ from confhub.core.block import BlockCore from confhub.core.fields import ConfigurationField +from confhub.utils.gitignore import add_to_gitignore logger: structlog.BoundLogger = structlog.get_logger("confhub") @@ -67,4 +68,7 @@ def create_files(self, config_path: Path) -> None: with open(file_path, 'w', encoding='utf-8') as file: yaml.dump(data, file, default_flow_style=False) + if filename.startswith('.'): + add_to_gitignore(f"{filename}.*") + logger.info("Create file", path=file_path) diff --git a/confhub/commands.py b/confhub/commands.py index adf92dc..49a6593 100644 --- a/confhub/commands.py +++ b/confhub/commands.py @@ -68,6 +68,4 @@ def generate_models() -> None: ConfigurationBuilder(*models).create_files(Path.cwd() / Path(_config_path)) - add_to_gitignore('.secrets.*') - logger.info("Configuration successfully generated")