Documentation
¶
Overview ¶
Package diff detects changed files between builds using Git or file hash comparison.
Index ¶
- func CheckConfigChange(manifest *model.BuildManifest, currentConfigHash string) bool
- func ClearCache(cacheDir string) error
- func DetectChanges(rootDir, fromCommit, toCommit string) (*model.ChangeSet, error)
- func IsGitRepo(dir string) bool
- func NewManifest(configHash string) *model.BuildManifest
- func ReadCachedHTML(cacheDir, slug string) (string, error)
- func ReadManifest(cacheDir string) (*model.BuildManifest, error)
- func WriteCachedHTML(cacheDir, slug, html string) error
- func WriteManifest(cacheDir string, m *model.BuildManifest) error
- type DiffEngine
- type GitDiffEngine
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 ¶
ClearCache removes all files under cacheDir.
func DetectChanges ¶
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 NewManifest ¶
func NewManifest(configHash string) *model.BuildManifest
NewManifest returns a fresh BuildManifest stamped with currentConfigHash.
func ReadCachedHTML ¶
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 ¶
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.