module

Noir::GitSnapshot

Materializes the files a git revision tracked into a scratch directory, so --diff-ref REF can scan the old side of a diff without the user checking it out first.

The checkout goes through a private index (GIT_INDEX_FILE) and checkout-index --prefix, which is plumbing: it writes files and nothing else. The user's HEAD, index and working tree are never touched, no ref moves, and no hook runs — git checkout <ref> -- <path> would have fired post-checkout, git worktree add leaves an entry in .git/worktrees that outlives a crashed scan.

Constants

REPOSITORY_ENV = ["GIT_DIR", "GIT_WORK_TREE", "GIT_IMPLICIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_PREFIX", "GIT_INDEX_FILE", "GIT_OBJECT_DIRECTORY", "GIT_ALTERNATE_OBJECT_DIRECTORIES", "GIT_SHALLOW_FILE", "GIT_GRAFT_FILE"] of ::String

Variables that tell git which repository and index to use. Git exports them to the hooks it runs, and a pre-push hook is a natural place for noir scan --diff-ref origin/main --fail-on ... — but there GIT_DIR is typically the relative .git, which stops resolving the moment -C moves into a subdirectory, and an inherited GIT_INDEX_FILE would point read-tree at the hook's own index. Each call names its repository with -C, so these are cleared for it. GIT_CONFIG_PARAMETERS/GIT_CONFIG_COUNT (the -c channel) are kept.

Instance methods

materialize(ref : String, base_paths : Array(String)) : Snapshot
Source

Nested types