Back to the room

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

Code Observatory / function

open_checkout

codeintel.git_source.open_checkout

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 (5)
SymbolFileResolved by
_auth_configgit_source.pysame file
_git_envgit_source.pysame file
_rungit_source.pysame file
Checkoutgit_source.pysame file
validate_refgit_source.pysame file
Called by (1)
SymbolFileResolved by
indexindexer.pythrough an import
Inside (1)
SymbolFileResolved by
git_sourcegit_source.pysame file
codeintel.git_source.open_checkoutbackend/app/codeintel/git_source.py, lines 409–443Open source
def open_checkout(ref: RepoRef, *, branch: str | None = None, token: str | None = None,                  timeout: int = 600) -> Checkout:    """Resolve ``ref`` at ``branch`` (default branch when None) to a :class:`Checkout`."""    branch = validate_ref(branch)    if ref.source_type == "local":        assert ref.local_path        git_dir = _run(["git", "-C", ref.local_path, "rev-parse", "--absolute-git-dir"], timeout=30).strip()        target = branch or "HEAD"        commit = _run(["git", f"--git-dir={git_dir}", "rev-parse", "--verify", f"{target}^{{commit}}"], timeout=30).strip()        return Checkout(git_dir, commit, branch=branch)    assert ref.clone_url    temp_dir = tempfile.mkdtemp(prefix="pharos_ingest_")    git_dir = os.path.join(temp_dir, "repo.git")    env = _git_env(_auth_config(ref, token))    try:        if branch and _SHA_RE.match(branch):            # A full commit SHA pins the exact tree (reproducible re-indexing);            # `clone --branch` only takes branch and tag names.            _run(["git", "init", "--bare", "--quiet", git_dir], timeout=30)            _run(["git", f"--git-dir={git_dir}", "fetch", "--depth", "1", "--no-tags", "--quiet", "--",                  ref.clone_url, branch], timeout=timeout, env=env)            target = "FETCH_HEAD^{commit}"        else:            args = ["git", "clone", "--bare", "--depth", "1", "--single-branch", "--no-tags", "--quiet"]            if branch:                args += ["--branch", branch]            _run([*args, "--", ref.clone_url, git_dir], timeout=timeout, env=env)            target = "HEAD^{commit}"        commit = _run(["git", f"--git-dir={git_dir}", "rev-parse", "--verify", target], timeout=30).strip()    except Exception:        shutil.rmtree(temp_dir, ignore_errors=True)        raise    logger.info("Cloned %s @ %s (branch=%s)", ref.canonical_url, commit[:12], branch or "default")    return Checkout(git_dir, commit, temp_dir=temp_dir, branch=branch)

What the index recorded

Signature
def open_checkout(ref: RepoRef, *, branch: str | None, token: str | None, timeout: int) -> Checkout:
File
backend/app/codeintel/git_source.py
Lines
409–443
Parser
python-ast
Git blob
6f88470169e4935929c5f865a974bd86da564c1a
Call sites
11 named, 5 resolved, 6 left unlinked
Outside this subset
5 more edges reach code outside the graph shown here

Read it on GitHub at this commit