{"modulePath":"github.com/glincker/stacklit","version":"v0.5.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package git\n\n## Variables\n\n```go\nvar RefreshHooks = []string{\"post-checkout\", \"post-merge\", \"post-rewrite\"}\n```\nRefreshHooks are the hooks that keep the index fresh after history moves without a commit: branch switches, pulls and rebases or amends.\n\n## Functions\n\n```go\nfunc ComputeMerkle(files []string, contents map[string][]byte) string\n```\nComputeMerkle 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.\n\n```go\nfunc ComputeMerkleFromLeaves(leaves map[string][]byte) string\n```\nComputeMerkleFromLeaves matches ComputeMerkle but takes precomputed leaf hashes (sha256 of path plus content), so file bodies need not stay in memory.\n\n```go\nfunc Head(root string) string\n```\nHead returns the abbreviated HEAD commit of root, or \"\" outside a repo.\n\n```go\nfunc HookBody(root string) string\n```\nHookBody is the post-commit snippet for root. It stages the configured index and mermaid outputs, so moving output.mermaid keeps the hook correct.\n\n```go\nfunc InstallHook(root string) error\n```\nInstallHook installs (or appends to) the post-commit git hook in root so that stacklit regenerates its output on every commit.\n\n  - If .git/hooks/ does not exist, an error is returned.\n  - If the hook already contains \"stacklit\", it is left unchanged.\n  - If the hook exists but lacks \"stacklit\", the script is appended.\n  - If the hook does not exist, it is created with mode 0755.\n\n```go\nfunc InstallRefreshHooks(root string) ([]string, error)\n```\nInstallRefreshHooks adds the refresh block to each hook in RefreshHooks, keeping any hook content already there. It returns the hooks it changed.\n\n```go\nfunc RemoveRefreshHooks(root string) ([]string, error)\n```\nRemoveRefreshHooks strips the refresh block and deletes hooks left empty.\n\n## Types\n\n```go\ntype Activity struct {\n\tHotFiles    []FileActivity `json:\"hot_files\"`\n\tRecentFiles []string       `json:\"recent\"`\n\tStableFiles []string       `json:\"stable\"`\n}\n```\nActivity summarises recent git churn for a repository.\n\n```go\nfunc GetActivity(root string, days int) (*Activity, error)\n```\nGetActivity analyses git history in root over the last days days. If git is unavailable or root is not a git repository, it returns an empty Activity without an error.\n\n```go\ntype FileActivity struct {\n\tPath       string `json:\"path\"`\n\tCommits90d int    `json:\"commits_90d\"`\n}\n```\nFileActivity records how many commits touched a file in a time window.\n\n```go\ntype Staleness struct {\n\tInRepo        bool\n\tHead          string\n\tCommitsBehind int\n\tChanged       []string\n}\n```\nStaleness describes how far the working tree has moved since an index was built.\n\n```go\nfunc CheckStale(root, builtCommit string, builtAt time.Time, keep func(string) bool) Staleness\n```\nCheckStale reports files changed since builtCommit (preferred) or, when the commit is unknown, since builtAt. keep filters which paths count.\n\n","path":"github.com/glincker/stacklit/internal/git","name":"git","synopsis":"","isRedistributable":true}
