Documentation
¶
Index ¶
- Variables
- func ComputeMerkle(files []string, contents map[string][]byte) string
- func ComputeMerkleFromLeaves(leaves map[string][]byte) string
- func Head(root string) string
- func HookBody(root string) string
- func InstallHook(root string) error
- func InstallRefreshHooks(root string) ([]string, error)
- func RemoveRefreshHooks(root string) ([]string, error)
- type Activity
- type FileActivity
- type Staleness
Constants ¶
This section is empty.
Variables ¶
var RefreshHooks = []string{"post-checkout", "post-merge", "post-rewrite"}
RefreshHooks are the hooks that keep the index fresh after history moves without a commit: branch switches, pulls and rebases or amends.
Functions ¶
func ComputeMerkle ¶
ComputeMerkle builds a Merkle tree from the provided files and their contents, returning the hex-encoded root hash. The same inputs always produce the same hash; changing any file path or its content produces a different hash. Returns an empty string when files is empty.
func ComputeMerkleFromLeaves ¶ added in v0.5.0
ComputeMerkleFromLeaves matches ComputeMerkle but takes precomputed leaf hashes (sha256 of path plus content), so file bodies need not stay in memory.
func HookBody ¶ added in v0.5.0
HookBody is the post-commit snippet for root. It stages the configured index and mermaid outputs, so moving output.mermaid keeps the hook correct.
func InstallHook ¶
InstallHook installs (or appends to) the post-commit git hook in root so that stacklit regenerates its output on every commit.
- If .git/hooks/ does not exist, an error is returned.
- If the hook already contains "stacklit", it is left unchanged.
- If the hook exists but lacks "stacklit", the script is appended.
- If the hook does not exist, it is created with mode 0755.
func InstallRefreshHooks ¶ added in v0.5.0
InstallRefreshHooks adds the refresh block to each hook in RefreshHooks, keeping any hook content already there. It returns the hooks it changed.
func RemoveRefreshHooks ¶ added in v0.5.0
RemoveRefreshHooks strips the refresh block and deletes hooks left empty.
Types ¶
type Activity ¶
type Activity struct {
HotFiles []FileActivity `json:"hot_files"`
RecentFiles []string `json:"recent"`
StableFiles []string `json:"stable"`
}
Activity summarises recent git churn for a repository.
type FileActivity ¶
FileActivity records how many commits touched a file in a time window.