trackedfiles

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir

func CacheDir(repoDir string) string

func ClearCache

func ClearCache(dir string) error

Types

type CachedIndex

type CachedIndex struct {
	// contains filtered or unexported fields
}

CachedIndex memoizes tracked file listings per root for one scan.

func NewCachedIndex

func NewCachedIndex(runner Runner) *CachedIndex

NewCachedIndex returns a memoizing index around runner.

func NewGitIndex

func NewGitIndex() *CachedIndex

NewGitIndex returns a per-run tracked-file index backed by git ls-files.

func (*CachedIndex) Files

func (i *CachedIndex) Files(root string) ([]string, bool)

Files returns a defensive copy of the tracked files for root.

type DiskStore

type DiskStore struct{}

DiskStore stores one listing per repository root.

func (DiskStore) Load

func (DiskStore) Load(root string, snapshot Snapshot) ([]string, bool)

func (DiskStore) Save

func (DiskStore) Save(root string, snapshot Snapshot, files []string) error

type FileMetadataProvider

type FileMetadataProvider struct{}

FileMetadataProvider reads git metadata directly from .git so warm checks do not pay the cost of listing the full repository.

func (FileMetadataProvider) Snapshot

func (FileMetadataProvider) Snapshot(root string) (Snapshot, bool)

type GitRunner

type GitRunner struct{}

GitRunner lists files tracked by the git worktree rooted at root.

func (GitRunner) List

func (GitRunner) List(root string) ([]string, bool)

type Index

type Index interface {
	Files(root string) ([]string, bool)
}

Index provides repository-relative tracked file paths for a root. Implementations return ok=false when callers should fall back to a filesystem walk.

type MetadataProvider

type MetadataProvider interface {
	Snapshot(root string) (Snapshot, bool)
}

MetadataProvider snapshots the git metadata that determines whether a tracked-file listing can be reused without invoking git ls-files.

type PersistentRunner

type PersistentRunner struct {
	// contains filtered or unexported fields
}

PersistentRunner wraps a Runner with a disk cache. It implements Runner so callers can keep using NewCachedIndex for per-run memoization.

func NewPersistentRunner

func NewPersistentRunner(runner Runner, meta MetadataProvider) *PersistentRunner

func NewPersistentRunnerWithStore

func NewPersistentRunnerWithStore(runner Runner, meta MetadataProvider, store Store) *PersistentRunner

func (*PersistentRunner) List

func (r *PersistentRunner) List(root string) ([]string, bool)

type Runner

type Runner interface {
	List(root string) ([]string, bool)
}

Runner is the pluggable backend used by CachedIndex. Tests can supply a fake runner to assert that multiple consumers share one discovery result.

type Snapshot

type Snapshot struct {
	Root         string `json:"root"`
	GitDir       string `json:"gitDir"`
	IndexPath    string `json:"indexPath"`
	IndexSize    int64  `json:"indexSize"`
	IndexModTime int64  `json:"indexModTime"`
	Head         string `json:"head"`
}

Snapshot is intentionally based on git metadata rather than worktree file mtimes. A modified tracked source file does not change the tracked-file set, while index or HEAD changes do.

type Store

type Store interface {
	Load(root string, snapshot Snapshot) ([]string, bool)
	Save(root string, snapshot Snapshot, files []string) error
}

Store persists tracked-file listings by root. Implementations treat all decode, version, or metadata mismatches as cache misses.

Jump to

Keyboard shortcuts

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