refactor(project-scanner): tidy manifest priority helpers
Agent-Logs-Url: https://github.com/MemPalace/mempalace/sessions/3c277c46-20b3-4a43-8eb7-8ee2eb3cb55a Co-authored-by: igorls <4753812+igorls@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
851ebebc29
commit
ec9084f4d8
@@ -164,18 +164,19 @@ def _parse_gomod(path: Path) -> Optional[str]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
MANIFEST_PARSERS = {
|
|
||||||
"package.json": _parse_package_json,
|
|
||||||
"pyproject.toml": _parse_pyproject,
|
|
||||||
"Cargo.toml": _parse_cargo,
|
|
||||||
"go.mod": _parse_gomod,
|
|
||||||
}
|
|
||||||
MANIFEST_PRIORITY = {
|
MANIFEST_PRIORITY = {
|
||||||
"pyproject.toml": 0,
|
"pyproject.toml": 0,
|
||||||
"package.json": 1,
|
"package.json": 1,
|
||||||
"Cargo.toml": 2,
|
"Cargo.toml": 2,
|
||||||
"go.mod": 3,
|
"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 ====================
|
# ==================== GIT HELPERS ====================
|
||||||
@@ -318,7 +319,7 @@ def _manifest_sort_key(entry: tuple[str, str, Path], repo_root: Path) -> tuple[i
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
depth = MAX_DEPTH + 1
|
depth = MAX_DEPTH + 1
|
||||||
rel_str = manifest_dir.as_posix()
|
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]:
|
def find_git_repos(root: Path, max_depth: int = MAX_DEPTH) -> list[Path]:
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ from mempalace.project_scanner import (
|
|||||||
to_detected_dict,
|
to_detected_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
GIT_ENV_ALLOWLIST = ("PATH", "HOME", "SystemRoot", "ComSpec", "TMPDIR", "TEMP", "TMP")
|
||||||
|
|
||||||
|
|
||||||
# ── manifest parsers ────────────────────────────────────────────────────
|
# ── manifest parsers ────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -228,7 +230,7 @@ def _git_test_env(name: str, email: str) -> dict[str, str]:
|
|||||||
"GIT_COMMITTER_NAME": name,
|
"GIT_COMMITTER_NAME": name,
|
||||||
"GIT_COMMITTER_EMAIL": email,
|
"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)
|
value = os.environ.get(key)
|
||||||
if value:
|
if value:
|
||||||
env[key] = value
|
env[key] = value
|
||||||
|
|||||||
Reference in New Issue
Block a user