Skip to content

Commit 13ff5ea

Browse files
committed
✨ Create .gitignore file inside .fastapi instead of editing the existing one
1 parent d158e20 commit 13ff5ea

2 files changed

Lines changed: 4 additions & 30 deletions

File tree

src/fastapi_cloud_cli/utils/apps.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ def get_app_config(path_to_deploy: Path) -> Optional[AppConfig]:
2929
3030
> Should I commit the ".fastapi" folder?
3131
No, you should not commit the ".fastapi" folder to your version control system.
32-
On creation, it will be automatically added to your ".gitignore" file.
32+
That's why we there's a ".gitignore" file in this folder.
3333
"""
3434

3535

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

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

47-
git_ignore_path = path_to_deploy / ".gitignore"
48-
49-
if not git_ignore_path.exists():
50-
git_ignore_path.write_text(".fastapi\n", encoding="utf-8")
51-
else:
52-
git_ignore_content = git_ignore_path.read_text(encoding="utf-8")
53-
54-
if ".fastapi" not in git_ignore_content:
55-
git_ignore_path.write_text(
56-
f"{git_ignore_content}.fastapi\n", encoding="utf-8"
57-
)
48+
gitignore_path.write_text("*")

tests/test_cli_deploy.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -567,21 +567,6 @@ def test_can_skip_waiting(
567567
assert "Check the status of your deployment at" in result.output
568568

569569

570-
@pytest.mark.respx(base_url=settings.base_api_url)
571-
def test_creates_config_folder_and_adds_it_to_gitignore(
572-
logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter
573-
) -> None:
574-
git_ignore_path = tmp_path / ".gitignore"
575-
git_ignore_path.write_text(".venv\n")
576-
577-
_deploy_without_waiting(respx_mock, tmp_path)
578-
579-
assert (tmp_path / ".fastapi" / "cloud.json").exists()
580-
assert (tmp_path / ".fastapi" / "README.md").exists()
581-
582-
assert git_ignore_path.read_text() == ".venv\n.fastapi\n"
583-
584-
585570
@pytest.mark.respx(base_url=settings.base_api_url)
586571
def test_creates_config_folder_and_creates_git_ignore(
587572
logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter
@@ -590,9 +575,7 @@ def test_creates_config_folder_and_creates_git_ignore(
590575

591576
assert (tmp_path / ".fastapi" / "cloud.json").exists()
592577
assert (tmp_path / ".fastapi" / "README.md").exists()
593-
assert (tmp_path / ".gitignore").exists()
594-
595-
assert (tmp_path / ".gitignore").read_text() == ".fastapi\n"
578+
assert (tmp_path / ".fastapi" / ".gitignore").read_text() == "*"
596579

597580

598581
@pytest.mark.respx(base_url=settings.base_api_url)

0 commit comments

Comments
 (0)