digest

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package digest computes git-blob hashes for indexed files. It reads HEAD-tree and staging-index blob SHAs via go-git (no shelling out) and falls back to hashing working-tree bytes for dirty or untracked files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

type Source struct {
	TreeBlobs  map[string]plumbing.Hash
	IndexBlobs map[string]plumbing.Hash
}

Source caches blob hashes for paths that go-git already knows about (tracked-and-clean files), avoiding rehashes during sync.

func Load

func Load(ctx context.Context, root string) (*Source, error)

Load opens the git repository rooted at root and prefetches blob hashes for the HEAD tree and the staging index. A non-git directory returns an empty Source (every file falls through to working-tree hashing).

func (*Source) For

func (s *Source) For(path string, body []byte) plumbing.Hash

For returns the git-blob hash to record for path. It prefers the staged blob (covers "staged but committed body is different"), then the HEAD tree, and finally hashes the working-tree body in-process. body is only read when the cache misses, so callers can pass nil for clean files.

func (*Source) Tracked

func (s *Source) Tracked(path string) bool

Tracked reports whether path is present in either the HEAD tree or the staging index. Useful when sync needs to decide whether to trust the cached hash without re-reading the file body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL