Internal

internal/adapters/git

Package git inspects workspace state through Git-backed adapters.

import "github.com/nilstate/scafld/v2/internal/adapters/git"

Package git inspects workspace state through Git-backed adapters.

Snapshot builds a commit-free fingerprint by writing the working tree through a temporary GIT_INDEX_FILE, seeded from HEAD when available, and then resolving a Git tree object. The real branch, index, HEAD, and stash are not mutated. Snapshot commands pin host core.autocrlf=false while preserving committed .gitattributes and filters as repository semantics.

Submodules are represented as gitlink entries: the snapshot records the opaque submodule commit pointer, not the nested submodule working tree.

Types

type Adapter

Source: internal/adapters/git/git.go:27

Adapter reads Git state from a workspace root.

type Adapter struct {
	Root string
}
Fields
  • Root string

func BaseDiffPaths(ctx context.Context, baseRef string) ([]string, error)

Source: internal/adapters/git/git.go:333

BaseDiffPaths returns deterministic changed paths between baseRef's merge-base with HEAD and the current commit-free working tree. Deleted paths are included so deletion-only changes can still define a no-spec gate scope.

func CanonicalBytes(ctx context.Context, treeSHA string, path string) ([]byte, error)

Source: internal/adapters/git/git.go:603

CanonicalBytes returns the committed blob bytes for path at the snapshot tree. It is the reviewer-evidence source: bytes come from the content-addressed tree object, never the mutable working file, so the reviewer reads exactly what the receipt fingerprints.

func ChangedFiles(ctx context.Context) ([]string, error)

Source: internal/adapters/git/git.go:172

ChangedFiles returns changed-file fingerprints for mutation guards.

func ExactStatus(ctx context.Context) (State, error)

Source: internal/adapters/git/git.go:105

ExactStatus returns every Git-visible difference in the worktree, including ignored files and scafld runtime paths. It is for execution roots where any byte on disk may be read by a command, so the narrower mutation-guard filters used by Status are intentionally not applied.

func IsAncestor(ctx context.Context, ancestor, descendant string) (bool, error)

Source: internal/adapters/git/git.go:384

IsAncestor reports whether ancestor is reachable from descendant.

func MaterialSeal(ctx context.Context, scope []string) (reviewevidence.MaterialSeal, error)

Source: internal/adapters/git/git.go:273

MaterialSeal returns a content digest for the current working tree under scope, independent of whether the bytes are dirty or committed.

func ResolveCommit(ctx context.Context, ref string) (string, error)

Source: internal/adapters/git/git.go:581

ResolveCommit returns the commit object identified by ref.

func ResolveHead(ctx context.Context) (string, bool, error)

Source: internal/adapters/git/git.go:587

ResolveHead returns the checked-out HEAD commit when the worktree has one. Repositories without an initial commit return ok=false instead of failing.

func Snapshot(ctx context.Context, input SnapshotInput) (Snapshot, error)

Source: internal/adapters/git/git.go:182

Snapshot writes the working tree to a temporary Git index and returns a content-addressed fingerprint without mutating the real index, HEAD, or stash.

func Status(ctx context.Context) (State, error)

Source: internal/adapters/git/git.go:77

Status returns the current changed-file fingerprints.

func StatusMaterialSeal(ctx context.Context, scope []string) (reviewevidence.MaterialSeal, error)

Source: internal/adapters/git/git.go:296

StatusMaterialSeal returns the same material digest shape as MaterialSeal for read-only status projection without rebuilding a full-repository temporary tree. Review and completion still use MaterialSeal so authority evidence keeps the strongest snapshot path.

func TreeBlobs(ctx context.Context, treeSHA string, paths []string) (map[string][]byte, error)

Source: internal/adapters/git/git.go:860

TreeBlobs reads the committed bytes of paths at the snapshot tree through one git cat-file --batch process. It is the batched form of CanonicalBytes: the bytes come from the content-addressed tree object, never the working files.

func TreeDigests(ctx context.Context, treeSHA string, scope []string) ([]FileDigest, error)

Source: internal/adapters/git/git.go:595

TreeDigests lists the in-scope file digests of an existing tree object, reading the immutable tree rather than the working directory. The gate reviewer uses it to read the exact bytes the receipt signs, regardless of any later working-tree mutation.

func TreeSHA(ctx context.Context, input SnapshotInput) (string, error)

Source: internal/adapters/git/git.go:967

TreeSHA computes only the commit-free snapshot tree fingerprint, skipping the per-file digest, diff, and ignored-path passes.

type DeletedPath

Source: internal/adapters/git/git.go:56

DeletedPath records an in-scope path deleted from the base commit.

type DeletedPath struct {
	Path   string
	Status string
}
Fields
  • Path string
  • Status string

type EvidenceIntegrityError

Source: internal/adapters/git/git.go:68

EvidenceIntegrityError reports index flags that can hide working-tree edits.

type EvidenceIntegrityError struct {
	Paths []string
}
Fields
  • Paths []string

func Error) Error() string

Source: internal/adapters/git/git.go:72

type FileDigest

Source: internal/adapters/git/git.go:49

FileDigest records a present path in the snapshot tree.

type FileDigest struct {
	Path   string
	Status string
	SHA256 string
}
Fields
  • Path string
  • Status string
  • SHA256 string

type IgnoredPath

Source: internal/adapters/git/git.go:62

IgnoredPath records an ignored path that was intentionally excluded.

type IgnoredPath struct {
	Path   string
	Reason string
}
Fields
  • Path string
  • Reason string

type Snapshot

Source: internal/adapters/git/git.go:39

Snapshot is a deterministic Git-backed workspace fingerprint.

type Snapshot struct {
	TreeSHA           string
	BaseCommit        string
	HeadCommit        string
	FileDigests       []FileDigest
	DeletedPaths      []DeletedPath
	IgnoredUnreviewed []IgnoredPath
}
Fields
  • TreeSHA string
  • BaseCommit string
  • HeadCommit string
  • FileDigests []FileDigest
  • DeletedPaths []DeletedPath
  • IgnoredUnreviewed []IgnoredPath

type SnapshotInput

Source: internal/adapters/git/git.go:32

SnapshotInput controls a commit-free Git tree snapshot.

type SnapshotInput struct {
	Scope     []string
	BaseRef   string
	TargetRef string
}
Fields
  • Scope []string
  • BaseRef string
  • TargetRef string

type State

Source: internal/adapters/git/git.go:22

State is the fingerprinted set of Git-visible workspace changes.

type State struct {
	Changed []string
}
Fields
  • Changed []string