Documentation
¶
Overview ¶
Package gitcli provides native git CLI execution for blame operations. It shells out to the system git binary for blame (which uses packfile indexes and runs in milliseconds) while the rest of stringer uses go-git for commit iteration, branch listing, and repo detection. See DR-011 for rationale.
Index ¶
- Constants
- func Available() error
- func Exec(ctx context.Context, repoDir string, args ...string) (string, error)
- func LastCommitTime(ctx context.Context, repoDir, path string) (time.Time, error)
- func ListTrackedFiles(ctx context.Context, repoDir string) (map[string]bool, error)
- func SetExecutor(e testable.CommandExecutor)
- type BlameLine
- type NumstatCommit
Constants ¶
const DefaultTimeout = 5 * time.Second
DefaultTimeout is the per-file blame timeout per DR-011.
Variables ¶
This section is empty.
Functions ¶
func Available ¶
func Available() error
Available returns nil if git is on PATH, or an error otherwise.
func LastCommitTime ¶ added in v0.5.1
LastCommitTime returns the author time of the most recent commit that touched the given path (file or directory). Returns zero time if no commits are found.
func ListTrackedFiles ¶ added in v1.9.0
ListTrackedFiles runs `git ls-files -z` in repoDir and returns the set of tracked file paths (relative to repoDir, slash-separated as git emits them). Returns an error when repoDir is not inside a git work tree or git is unavailable.
func SetExecutor ¶ added in v0.5.1
func SetExecutor(e testable.CommandExecutor)
SetExecutor replaces the package-level CommandExecutor. Pass nil to restore the default production executor. This is intended for testing.
Types ¶
type BlameLine ¶
BlameLine holds attribution data for a single source line.
type NumstatCommit ¶ added in v1.0.0
NumstatCommit holds parsed data from a single commit in git log --numstat output.
func LogNumstat ¶ added in v1.0.0
func LogNumstat(ctx context.Context, repoDir string, maxCount int, since string) ([]NumstatCommit, error)
LogNumstat runs `git log --numstat --format=...` and returns structured per-commit data. maxCount limits the number of commits returned. If since is non-empty, it is passed as --since=<value>.