diff --git a/mempalace/project_scanner.py b/mempalace/project_scanner.py index f426e8f..eaab560 100644 --- a/mempalace/project_scanner.py +++ b/mempalace/project_scanner.py @@ -164,18 +164,19 @@ def _parse_gomod(path: Path) -> Optional[str]: return None -MANIFEST_PARSERS = { - "package.json": _parse_package_json, - "pyproject.toml": _parse_pyproject, - "Cargo.toml": _parse_cargo, - "go.mod": _parse_gomod, -} MANIFEST_PRIORITY = { "pyproject.toml": 0, "package.json": 1, "Cargo.toml": 2, "go.mod": 3, } +UNKNOWN_MANIFEST_PRIORITY = 999 +MANIFEST_PARSERS = { + "package.json": _parse_package_json, + "pyproject.toml": _parse_pyproject, + "Cargo.toml": _parse_cargo, + "go.mod": _parse_gomod, +} # ==================== GIT HELPERS ==================== @@ -318,7 +319,7 @@ def _manifest_sort_key(entry: tuple[str, str, Path], repo_root: Path) -> tuple[i except ValueError: depth = MAX_DEPTH + 1 rel_str = manifest_dir.as_posix() - return (depth, MANIFEST_PRIORITY.get(manifest_file, len(MANIFEST_PRIORITY)), rel_str) + return (depth, MANIFEST_PRIORITY.get(manifest_file, UNKNOWN_MANIFEST_PRIORITY), rel_str) def find_git_repos(root: Path, max_depth: int = MAX_DEPTH) -> list[Path]: diff --git a/tests/test_project_scanner.py b/tests/test_project_scanner.py index 821f527..4fcb6dd 100644 --- a/tests/test_project_scanner.py +++ b/tests/test_project_scanner.py @@ -27,6 +27,8 @@ from mempalace.project_scanner import ( to_detected_dict, ) +GIT_ENV_ALLOWLIST = ("PATH", "HOME", "SystemRoot", "ComSpec", "TMPDIR", "TEMP", "TMP") + # ── manifest parsers ──────────────────────────────────────────────────── @@ -228,7 +230,7 @@ def _git_test_env(name: str, email: str) -> dict[str, str]: "GIT_COMMITTER_NAME": name, "GIT_COMMITTER_EMAIL": email, } - for key in ("PATH", "HOME", "SystemRoot", "ComSpec", "TMPDIR", "TEMP", "TMP"): + for key in GIT_ENV_ALLOWLIST: value = os.environ.get(key) if value: env[key] = value