gitcli

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 7 Imported by: 0

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

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

func Exec(ctx context.Context, repoDir string, args ...string) (string, error)

Exec runs git with the given arguments in repoDir and returns combined stdout.

func LastCommitTime added in v0.5.1

func LastCommitTime(ctx context.Context, repoDir, path string) (time.Time, error)

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

type BlameLine struct {
	AuthorName string
	AuthorTime time.Time
}

BlameLine holds attribution data for a single source line.

func BlameFile

func BlameFile(ctx context.Context, repoDir, relPath string) ([]BlameLine, error)

BlameFile runs `git blame --porcelain -- <relPath>` and returns one BlameLine per source line.

func BlameSingleLine

func BlameSingleLine(ctx context.Context, repoDir, relPath string, line int) (*BlameLine, error)

BlameSingleLine runs `git blame --porcelain -L <line>,<line> -- <relPath>` and returns the attribution for that line.

type NumstatCommit added in v1.0.0

type NumstatCommit struct {
	SHA        string
	Author     string
	AuthorTime time.Time
	Files      []string
}

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

Jump to

Keyboard shortcuts

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