Documentation
¶
Overview ¶
Package gitutil provides shared Git repository helpers used across multiple internal packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitsSince ¶ added in v1.20.0
CommitsSince returns the number of commits touching each file under root since the given duration ago. Uses `git log --since=<dur> --name-only --pretty=format:` and counts file occurrences. Returns empty map on any error (best-effort — no error returned). Timeout: 5s.
func FileDiffSince ¶ added in v1.20.0
func FileDiffSince(ctx context.Context, root, file string, since time.Duration, maxLines int) string
FileDiffSince returns a unified diff of file (relative to root) between the commit at HEAD and the commit just before the since-duration window. Caps output at maxLines diff lines (excluding git diff header). Returns "" on any error or if file unchanged. Timeout: 10s.
func IsGitRepo ¶
IsGitRepo reports whether root is the root of a git repository.
It accepts both forms of the .git entry:
- a directory: standard single-worktree repository
- a regular file: linked worktree created by "git worktree add" (the file contains a "gitdir: ..." pointer to the main repo)
Anything other than a stat error at <root>/.git is treated as a valid git repo — downstream git commands will surface a more precise error if the entry is malformed.
Types ¶
This section is empty.