Skip to content

Commit 6477ce4

Browse files
authored
chore: detect project folder more correctly (#69)
1 parent 84f72d0 commit 6477ce4

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/cocoindex_code/settings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def default_project_settings() -> ProjectSettings:
110110
# ---------------------------------------------------------------------------
111111

112112
_SETTINGS_DIR_NAME = ".cocoindex_code"
113-
_SETTINGS_FILE_NAME = "settings.yml"
113+
_SETTINGS_FILE_NAME = "settings.yml" # project-level
114+
_USER_SETTINGS_FILE_NAME = "global_settings.yml" # user-level
114115

115116

116117
def user_settings_dir() -> Path:
@@ -127,8 +128,8 @@ def user_settings_dir() -> Path:
127128

128129

129130
def user_settings_path() -> Path:
130-
"""Return ``~/.cocoindex_code/settings.yml``."""
131-
return user_settings_dir() / _SETTINGS_FILE_NAME
131+
"""Return ``~/.cocoindex_code/global_settings.yml``."""
132+
return user_settings_dir() / _USER_SETTINGS_FILE_NAME
132133

133134

134135
def project_settings_path(project_root: Path) -> Path:

tests/test_backward_compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_legacy_entry_creates_settings_from_env_vars(
3131
)
3232
monkeypatch.setattr(
3333
"cocoindex_code.settings.user_settings_path",
34-
lambda: tmp_path / "user" / "settings.yml",
34+
lambda: tmp_path / "user" / "global_settings.yml",
3535
)
3636

3737
# Simulate env vars
@@ -56,7 +56,7 @@ def test_legacy_entry_respects_existing_settings(
5656
)
5757
monkeypatch.setattr(
5858
"cocoindex_code.settings.user_settings_path",
59-
lambda: tmp_path / "user" / "settings.yml",
59+
lambda: tmp_path / "user" / "global_settings.yml",
6060
)
6161

6262
custom = UserSettings(

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def daemon_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> tuple[Path, s
4343
monkeypatch.setattr("cocoindex_code.settings.user_settings_dir", lambda: user_dir)
4444
monkeypatch.setattr(
4545
"cocoindex_code.settings.user_settings_path",
46-
lambda: user_dir / "settings.yml",
46+
lambda: user_dir / "global_settings.yml",
4747
)
4848
save_user_settings(default_user_settings())
4949

tests/test_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _patch_user_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
3333
)
3434
monkeypatch.setattr(
3535
"cocoindex_code.settings.user_settings_path",
36-
lambda: tmp_path / ".cocoindex_code" / "settings.yml",
36+
lambda: tmp_path / ".cocoindex_code" / "global_settings.yml",
3737
)
3838

3939

0 commit comments

Comments
 (0)