From ce09070805b8af97defc1b84e838239acfd1f46f Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Thu, 15 Jan 2026 09:43:35 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=92=20Exclude=20.env=20files=20fro?= =?UTF-8?q?m=20deployment=20uploads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fastapi_cloud_cli/commands/deploy.py | 3 +++ tests/test_deploy_utils.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/fastapi_cloud_cli/commands/deploy.py b/src/fastapi_cloud_cli/commands/deploy.py index e94c3f8..23db09d 100644 --- a/src/fastapi_cloud_cli/commands/deploy.py +++ b/src/fastapi_cloud_cli/commands/deploy.py @@ -62,6 +62,9 @@ def _should_exclude_entry(path: Path) -> bool: if path.suffix == ".pyc": return True + if path.name == ".env" or path.name.startswith(".env."): + return True + return False diff --git a/tests/test_deploy_utils.py b/tests/test_deploy_utils.py index 1119d5d..428486c 100644 --- a/tests/test_deploy_utils.py +++ b/tests/test_deploy_utils.py @@ -19,6 +19,11 @@ Path(".venv"), Path("__pycache__"), Path("module.pyc"), + Path("/project/.env"), + Path("/project/.env.local"), + Path("/project/.env.production"), + Path(".env"), + Path(".env.development"), ], ) def test_excludes_paths(path: Path) -> None: @@ -37,6 +42,8 @@ def test_excludes_paths(path: Path) -> None: Path("/project/src/module.pyx"), # similar to .pyc but different Path("/project/config.json"), Path("/project/README.md"), + Path("/project/.envrc"), # not a .env file + Path("/project/env.py"), # not a .env file ], ) def test_includes_paths(path: Path) -> None: From f6dfa05470bacd3eeb3442a61b3d3c2d4c85cc04 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Thu, 15 Jan 2026 09:46:19 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20Update=20test=20to=20expect=20.?= =?UTF-8?q?env=20exclusion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_archive.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_archive.py b/tests/test_archive.py index e74d8eb..2d358c5 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -143,12 +143,13 @@ def test_archive_respects_fastapicloudignore_unignore( } -def test_archive_includes_hidden_files( +def test_archive_includes_hidden_files_but_excludes_env( src_path: Path, tar_path: Path, dst_path: Path ) -> None: - """Should include hidden files in the archive by default.""" + """Should include hidden files but exclude .env files.""" (src_path / "main.py").write_text("print('hello')") (src_path / ".env").write_text("SECRET_KEY=xyz") + (src_path / ".env.local").write_text("LOCAL_KEY=abc") (src_path / ".config").mkdir() (src_path / ".config" / "settings.json").write_text('{"setting": "value"}') @@ -159,7 +160,6 @@ def test_archive_includes_hidden_files( assert set(dst_path.glob("**/*")) == { dst_path / "main.py", - dst_path / ".env", dst_path / ".config", dst_path / ".config" / "settings.json", }