git

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func ComputeMerkle(files []string, contents map[string][]byte) string

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

func ComputeMerkleFromLeaves(leaves map[string][]byte) string

ComputeMerkleFromLeaves matches ComputeMerkle but takes precomputed leaf hashes (sha256 of path plus content), so file bodies need not stay in memory.

func Head(root string) string

Head returns the abbreviated HEAD commit of root, or "" outside a repo.

func HookBody added in v0.5.0

func HookBody(root string) string

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

func InstallHook(root string) error

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

func InstallRefreshHooks(root string) ([]string, error)

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

func RemoveRefreshHooks(root string) ([]string, error)

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.

func GetActivity

func GetActivity(root string, days int) (*Activity, error)

GetActivity 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.

type FileActivity

type FileActivity struct {
	Path       string `json:"path"`
	Commits90d int    `json:"commits_90d"`
}

FileActivity records how many commits touched a file in a time window.

type Staleness added in v0.5.0

type Staleness struct {
	InRepo        bool
	Head          string
	CommitsBehind int
	Changed       []string
}

Staleness describes how far the working tree has moved since an index was built.

func CheckStale added in v0.5.0

func CheckStale(root, builtCommit string, builtAt time.Time, keep func(string) bool) Staleness

CheckStale reports files changed since builtCommit (preferred) or, when the commit is unknown, since builtAt. keep filters which paths count.

Jump to

Keyboard shortcuts

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