generated from coulomb/repo-seed
Git ingestion part of Milestone 2
This commit is contained in:
@@ -10,6 +10,7 @@ from repo_registry.core.models import (
|
||||
ScanSummary,
|
||||
SearchResult,
|
||||
)
|
||||
from repo_registry.repo_ingestion.git import GitIngestionService
|
||||
from repo_registry.repo_scanning.scanner import DeterministicScanner
|
||||
from repo_registry.storage.sqlite import RegistryStore
|
||||
|
||||
@@ -17,9 +18,14 @@ from repo_registry.storage.sqlite import RegistryStore
|
||||
class RegistryService:
|
||||
"""Application service for the manual registry MVP."""
|
||||
|
||||
def __init__(self, store: RegistryStore) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
store: RegistryStore,
|
||||
ingestion: GitIngestionService | None = None,
|
||||
) -> None:
|
||||
self.store = store
|
||||
self.scanner = DeterministicScanner()
|
||||
self.ingestion = ingestion or GitIngestionService()
|
||||
|
||||
def register_repository(
|
||||
self,
|
||||
@@ -52,7 +58,12 @@ class RegistryService:
|
||||
run = self.store.create_analysis_run(repository_id)
|
||||
self.store.update_repository_status(repository_id, "analyzing")
|
||||
try:
|
||||
scan_result = self.scanner.scan(source_path or repository.url)
|
||||
if source_path is None:
|
||||
checkout = self.ingestion.resolve(repository.url, branch=repository.branch)
|
||||
scan_source = checkout.source_path
|
||||
else:
|
||||
scan_source = source_path
|
||||
scan_result = self.scanner.scan(scan_source)
|
||||
except Exception as exc:
|
||||
failed_run = self.store.fail_analysis_run(repository_id, run.id, str(exc))
|
||||
return ScanSummary(analysis_run=failed_run, snapshot=None, facts=[])
|
||||
|
||||
Reference in New Issue
Block a user