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:209

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:401

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:123

ChangedFiles returns changed-file fingerprints for mutation guards.

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

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

IsAncestor reports whether ancestor is reachable from descendant.

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

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

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

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

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

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:133

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:76

Status returns the current changed-file fingerprints.

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

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

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:393

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:699

TreeSHA computes only the commit-free snapshot tree fingerprint, skipping the per-file digest, diff, and ignored-path passes. The finalize mutation guard uses it to detect acceptance-time drift without paying for a full snapshot.

type DeletedPath

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

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:67

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:71

type FileDigest

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

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:61

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:38

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
}
Fields
  • Scope []string
  • BaseRef 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