Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,25 @@ def test_archive_respects_fastapicloudignore(tmp_path: Path) -> None:
"main.py",
"config.py",
}


def test_archive_respects_fastapicloudignore_unignore(tmp_path: Path) -> None:
"""Test we can use .fastapicloudignore to unignore files inside .gitignore"""
# Create test files
(tmp_path / "main.py").write_text("print('hello')")
(tmp_path / "static/build").mkdir(exist_ok=True, parents=True)
(tmp_path / "static/build/style.css").write_text("body { background: #bada55 }")
# Rignore needs a .git folder to make .gitignore work
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we okay with that restriction?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe? :D the only case I can think of where this is problematic is when you're starting a new project and deploy before creating a git repo πŸ€”

(tmp_path / ".git").mkdir(exist_ok=True, parents=True)
(tmp_path / ".gitignore").write_text("build/")

# Create .fastapicloudignore file
(tmp_path / ".fastapicloudignore").write_text("!static/build")

# Create archive
tar_path = archive(tmp_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"}