Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / function

read_file_at_commit

codeintel.git_source.read_file_at_commit

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Calls (2)
SymbolFileResolved by
_git_envgit_source.pysame file
GitErrorgit_source.pysame file
Called by (1)
SymbolFileResolved by
_loadsource.pythrough an import
Inside (1)
SymbolFileResolved by
git_sourcegit_source.pysame file
codeintel.git_source.read_file_at_commitbackend/app/codeintel/git_source.py, lines 446–461Open source
def read_file_at_commit(git_dir: str, commit: str, path: str) -> bytes:    """Read ``path`` at ``commit`` from a local repository (code resolution)."""    if not _SHA_RE.match(commit):        raise ValueError("commit must be a full SHA")    if path.startswith("/") or ".." in path.split("/"):        raise ValueError("invalid path")    proc = subprocess.run(        ["git", f"--git-dir={git_dir}", "cat-file", "blob", f"{commit}:{path}"],        capture_output=True,        timeout=30,        env=_git_env(),        check=False,    )    if proc.returncode != 0:        raise GitError("file not found at commit", retryable=False)    return proc.stdout

What the index recorded

Signature
def read_file_at_commit(git_dir: str, commit: str, path: str) -> bytes:
File
backend/app/codeintel/git_source.py
Lines
446–461
Parser
python-ast
Git blob
6f88470169e4935929c5f865a974bd86da564c1a
Call sites
7 named, 2 resolved, 5 left unlinked

Read it on GitHub at this commit