From 7ce563d16f478b045a05a7aade42244d145bc8d3 Mon Sep 17 00:00:00 2001 From: Marco Burro Date: Tue, 18 Nov 2025 15:38:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Include=20hidden=20files=20in=20?= =?UTF-8?q?app=20archive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fastapi_cloud_cli/commands/deploy.py | 10 +++++++- tests/test_archive.py | 32 +++++++++++++++++------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/fastapi_cloud_cli/commands/deploy.py b/src/fastapi_cloud_cli/commands/deploy.py index a94298c..b1a05a1 100644 --- a/src/fastapi_cloud_cli/commands/deploy.py +++ b/src/fastapi_cloud_cli/commands/deploy.py @@ -34,7 +34,14 @@ def _get_app_name(path: Path) -> str: def _should_exclude_entry(path: Path) -> bool: - parts_to_exclude = [".venv", "__pycache__", ".mypy_cache", ".pytest_cache"] + parts_to_exclude = [ + ".venv", + "__pycache__", + ".mypy_cache", + ".pytest_cache", + ".gitignore", + ".fastapicloudignore", + ] if any(part in path.parts for part in parts_to_exclude): return True @@ -51,6 +58,7 @@ def archive(path: Path, tar_path: Path) -> Path: path, should_exclude_entry=_should_exclude_entry, additional_ignore_paths=[".fastapicloudignore"], + ignore_hidden=False, ) logger.debug("Archive will be created at: %s", tar_path) diff --git a/tests/test_archive.py b/tests/test_archive.py index 6bbcd63..7d14d7e 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -72,20 +72,16 @@ def test_archive_preserves_relative_paths(src_path: Path, tar_path: Path) -> Non def test_archive_respects_fastapicloudignore(src_path: Path, tar_path: Path) -> None: """Should exclude files specified in .fastapicloudignore.""" - # Create test files (src_path / "main.py").write_text("print('hello')") (src_path / "config.py").write_text("CONFIG = 'value'") (src_path / "secrets.env").write_text("SECRET_KEY=xyz") (src_path / "data").mkdir() (src_path / "data" / "file.txt").write_text("data") - # Create .fastapicloudignore file (src_path / ".fastapicloudignore").write_text("secrets.env\ndata/\n") - # Create archive archive(src_path, tar_path) - # Verify ignored files are excluded with tarfile.open(tar_path, "r") as tar: names = tar.getnames() assert set(names) == { @@ -98,21 +94,39 @@ def test_archive_respects_fastapicloudignore_unignore( src_path: Path, tar_path: Path ) -> None: """Test we can use .fastapicloudignore to unignore files inside .gitignore""" - # Create test files (src_path / "main.py").write_text("print('hello')") + + (src_path / "ignore_me.txt").write_text("You should ignore me") + (src_path / "static/build").mkdir(exist_ok=True, parents=True) (src_path / "static/build/style.css").write_text("body { background: #bada55 }") + # Rignore needs a .git folder to make .gitignore work (src_path / ".git").mkdir(exist_ok=True, parents=True) - (src_path / ".gitignore").write_text("build/") + (src_path / ".gitignore").write_text("ignore_me.txt\nbuild/") - # Create .fastapicloudignore file (src_path / ".fastapicloudignore").write_text("!static/build") - # Create archive archive(src_path, tar_path) - # Verify ignored files are excluded with tarfile.open(tar_path, "r") as tar: names = tar.getnames() assert set(names) == {"main.py", "static/build/style.css"} + + +def test_archive_includes_hidden_files(src_path: Path, tar_path: Path) -> None: + """Should include hidden files in the archive by default.""" + (src_path / "main.py").write_text("print('hello')") + (src_path / ".env").write_text("SECRET_KEY=xyz") + (src_path / ".config").mkdir() + (src_path / ".config" / "settings.json").write_text('{"setting": "value"}') + + archive(src_path, tar_path) + + with tarfile.open(tar_path, "r") as tar: + names = tar.getnames() + assert set(names) == { + "main.py", + ".env", + ".config/settings.json", + }