diff

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package diff detects changed files between builds using Git or file hash comparison.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConfigChange

func CheckConfigChange(manifest *model.BuildManifest, currentConfigHash string) bool

CheckConfigChange returns true when the hash stored for configHashKey in manifest differs from currentConfigHash. A nil manifest is treated as changed (first build).

func ClearCache

func ClearCache(cacheDir string) error

ClearCache removes all files under cacheDir.

func DetectChanges

func DetectChanges(rootDir, fromCommit, toCommit string) (*model.ChangeSet, error)

DetectChanges runs git diff --name-status between fromCommit and toCommit in rootDir and returns a ChangeSet. Falls back to an empty ChangeSet with an error when rootDir is not a Git repo.

func IsGitRepo

func IsGitRepo(dir string) bool

IsGitRepo reports whether dir is inside a Git working tree.

func NewManifest

func NewManifest(configHash string) *model.BuildManifest

NewManifest returns a fresh BuildManifest stamped with currentConfigHash.

func ReadCachedHTML

func ReadCachedHTML(cacheDir, slug string) (string, error)

ReadCachedHTML returns the cached HTML for slug from cacheDir/html/<slug>.html. Returns ("", nil) when not present.

func ReadManifest

func ReadManifest(cacheDir string) (*model.BuildManifest, error)

ReadManifest loads the BuildManifest from cacheDir/manifest.json. Returns nil (no error) when the file does not exist yet.

func WriteCachedHTML

func WriteCachedHTML(cacheDir, slug, html string) error

WriteCachedHTML stores html under cacheDir/html/<slug>.html.

func WriteManifest

func WriteManifest(cacheDir string, m *model.BuildManifest) error

WriteManifest persists m to cacheDir/manifest.json, creating directories as needed.

Types

type DiffEngine

type DiffEngine interface {
	// Detect compares the current working tree against the provided manifest
	// and returns the set of files that are new, modified, or deleted.
	Detect(manifest *model.BuildManifest) (*model.ChangeSet, error)

	// Hash returns the SHA-256 hex digest for the file at filePath.
	Hash(filePath string) (string, error)
}

DiffEngine detects which source files have changed since the last build, returning a ChangeSet used by dependent packages to skip unchanged work.

type GitDiffEngine

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

GitDiffEngine implements DiffEngine using file hashes with an optional git-accelerated change list.

func NewGitDiffEngine

func NewGitDiffEngine(rootDir string) *GitDiffEngine

NewGitDiffEngine returns a GitDiffEngine rooted at rootDir.

func (*GitDiffEngine) Detect

func (g *GitDiffEngine) Detect(manifest *model.BuildManifest) (*model.ChangeSet, error)

Detect compares the current working tree against manifest. When manifest is nil, every file under rootDir is returned as Added (full-build signal). Otherwise files whose SHA-256 hash has changed are returned as Modified, newly added files as Added, and missing files as Deleted.

func (*GitDiffEngine) Hash

func (g *GitDiffEngine) Hash(filePath string) (string, error)

Hash returns the SHA-256 hex digest of the file at filePath.

Jump to

Keyboard shortcuts

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