Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 3 additions & 12 deletions src/fastapi_cloud_cli/utils/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ def get_app_config(path_to_deploy: Path) -> Optional[AppConfig]:

> Should I commit the ".fastapi" folder?
No, you should not commit the ".fastapi" folder to your version control system.
On creation, it will be automatically added to your ".gitignore" file.
That's why we there's a ".gitignore" file in this folder.
Comment thread
patrick91 marked this conversation as resolved.
Outdated
"""


def write_app_config(path_to_deploy: Path, app_config: AppConfig) -> None:
config_path = path_to_deploy / ".fastapi/cloud.json"
readme_path = path_to_deploy / ".fastapi/README.md"
gitignore_path = path_to_deploy / ".fastapi/.gitignore"
config_path.parent.mkdir(parents=True, exist_ok=True)

config_path.write_text(
Expand All @@ -44,14 +45,4 @@ def write_app_config(path_to_deploy: Path, app_config: AppConfig) -> None:
)
readme_path.write_text(README, encoding="utf-8")

git_ignore_path = path_to_deploy / ".gitignore"

if not git_ignore_path.exists():
git_ignore_path.write_text(".fastapi\n", encoding="utf-8")
else:
git_ignore_content = git_ignore_path.read_text(encoding="utf-8")

if ".fastapi" not in git_ignore_content:
git_ignore_path.write_text(
f"{git_ignore_content}.fastapi\n", encoding="utf-8"
)
gitignore_path.write_text("*")
19 changes: 1 addition & 18 deletions tests/test_cli_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,21 +567,6 @@ def test_can_skip_waiting(
assert "Check the status of your deployment at" in result.output


@pytest.mark.respx(base_url=settings.base_api_url)
def test_creates_config_folder_and_adds_it_to_gitignore(
logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter
) -> None:
git_ignore_path = tmp_path / ".gitignore"
git_ignore_path.write_text(".venv\n")

_deploy_without_waiting(respx_mock, tmp_path)

assert (tmp_path / ".fastapi" / "cloud.json").exists()
assert (tmp_path / ".fastapi" / "README.md").exists()

assert git_ignore_path.read_text() == ".venv\n.fastapi\n"


@pytest.mark.respx(base_url=settings.base_api_url)
def test_creates_config_folder_and_creates_git_ignore(
logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter
Expand All @@ -590,9 +575,7 @@ def test_creates_config_folder_and_creates_git_ignore(

assert (tmp_path / ".fastapi" / "cloud.json").exists()
assert (tmp_path / ".fastapi" / "README.md").exists()
assert (tmp_path / ".gitignore").exists()

assert (tmp_path / ".gitignore").read_text() == ".fastapi\n"
assert (tmp_path / ".fastapi" / ".gitignore").read_text() == "*"


@pytest.mark.respx(base_url=settings.base_api_url)
Expand Down
Loading