Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/gitingest/ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ def ingest_query(query: IngestionQuery) -> tuple[str, str, str]:
logger.error("Expected file but found non-file", extra={"path": str(path)})
msg = f"Path {path} is not a file"
raise ValueError(msg)

if query.url:
from gitingest.utils.git_utils import create_git_repo
repo = create_git_repo(str(query.local_path), query.url)

try:
# Verify the path exists in the specific Git reference
rev_path = f"{query.commit or query.branch or 'HEAD'}:{query.subpath.lstrip('/')}"
repo.git.rev_parse("--verify", rev_path)
except Exception as exc:
msg = f"File '{query.subpath}' not found in the requested Git reference."
raise ValueError(msg) from exc

relative_path = path.relative_to(query.local_path)

Expand Down