Git ingestion part of Milestone 2

This commit is contained in:
2026-04-25 22:37:06 +02:00
parent 3d9032a386
commit ef41a9974a
8 changed files with 185 additions and 7 deletions

View File

@@ -1,11 +1,14 @@
import subprocess
from repo_registry.core.service import RegistryService
from repo_registry.repo_ingestion.git import GitIngestionService
from repo_registry.storage.sqlite import NotFoundError, RegistryStore
def make_service(tmp_path):
store = RegistryStore(tmp_path / "registry.sqlite3")
store.initialize()
return RegistryService(store)
return RegistryService(store, ingestion=GitIngestionService(tmp_path / "checkouts"))
def test_manual_registry_builds_ability_map(tmp_path):
@@ -144,3 +147,35 @@ def test_analyze_repository_failure_is_recorded(tmp_path):
assert summary.snapshot is None
assert "does not exist" in (summary.analysis_run.error_message or "")
assert service.get_repository(repository.id).status == "analysis_failed"
def test_analyze_repository_clones_git_url_before_scanning(tmp_path):
source = tmp_path / "git-source"
source.mkdir()
subprocess.run(["git", "init", "-b", "main"], cwd=source, check=True)
subprocess.run(
["git", "config", "user.email", "tests@example.com"],
cwd=source,
check=True,
)
subprocess.run(
["git", "config", "user.name", "Tests"],
cwd=source,
check=True,
)
(source / "README.md").write_text("# Git Source\n", encoding="utf-8")
(source / "requirements.txt").write_text("pytest\n", encoding="utf-8")
subprocess.run(["git", "add", "."], cwd=source, check=True)
subprocess.run(["git", "commit", "-m", "initial"], cwd=source, check=True)
service = make_service(tmp_path)
repository = service.register_repository(name="Git Source", url=source.as_uri())
summary = service.analyze_repository(repository.id)
assert summary.analysis_run.status == "completed"
assert summary.snapshot is not None
assert str(tmp_path / "checkouts") in summary.snapshot.source_path
fact_names = {(fact.kind, fact.name, fact.path) for fact in summary.facts}
assert ("documentation", "README", "README.md") in fact_names
assert ("framework", "pytest", "requirements.txt") in fact_names