Skip to main content

Module ops

Module ops 

Source

Functions§

clone_or_fetch
Clone url into dest, or fetch all refs if the repo already exists.
create_worktree
Create a detached worktree at worktree_path pointing at ref_name.
destroy_worktree
Remove a worktree previously created with create_worktree.
get_sha
Resolve ref_name to its full SHA in repo.
host_allowlist_configured
True when SLOC_GIT_HOST_ALLOWLIST names at least one host. Callers use this to decide whether network operations that fetch attacker-influenced URLs (e.g. submodule population on a network-facing server) may proceed under the positive allowlist.
is_local_repo_path
True when s points at an existing local git repository — a directory containing a .git entry (working tree or worktree/submodule pointer) or a bare repository dir.
list_commits
Return up to limit commits reachable from ref_name.
list_refs
Return all branches, tags, and recent commits for repo.
list_refs_local
Like list_refs, but for a repository operated on in place (a local checkout the user pointed us at). It lists the repo’s local branch heads (git branch) rather than remote-tracking refs (git branch -r), because a working repo’s branches of interest are its local heads. Tags and recent commits are listed identically to list_refs.
normalize_git_url
Convert a repository browse URL into a clonable git URL.
open_local_repo
Verify that path is inside a git repository and return the canonical repository root (the working-tree top level, or the given path for a bare repo). Runs no network I/O.
populate_submodules
Recursively check out a super-repo’s submodules inside worktree so their files are present for analysis. Best-effort: a repo with no .gitmodules is a no-op, and a submodule whose fetch fails simply stays empty (its per-submodule breakdown is then blank) rather than failing the whole scan.
publish_dir
Publish the contents of src_dir into repo_url on branch, under subdir, as a single commit, then push. work_dir is a caller-owned empty scratch directory used as the clone working tree.
resolve_committish
Resolve a user-facing ref name to a concrete commit SHA the worktree/scan commands accept.