vcs

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Churn

func Churn(ctx context.Context, root string, window time.Duration) (map[string]ChurnStat, error)

Churn reports per-file change activity over the trailing window, keyed by slash-separated path relative to root. Only production Go files count: churn in tests is not production exposure, and churn in non-Go files is not this tool's business.

func DirtyPaths

func DirtyPaths(ctx context.Context, root string) ([]string, error)

func HeadCommit

func HeadCommit(ctx context.Context, root string) (string, error)

func IsIgnored

func IsIgnored(ctx context.Context, root, path string) bool

IsIgnored reports whether git would ignore path. Worth checking before writing anything meant to be committed: a stray rule like `coverage/` in a root .gitignore can silently swallow a whole directory, and the failure is invisible until someone checks out the result.

func IsShallow

func IsShallow(ctx context.Context, root string) bool

func RepoRoot

func RepoRoot(ctx context.Context, dir string) (string, error)

func ShortSHA

func ShortSHA(sha string) string

func TreeDigests

func TreeDigests(ctx context.Context, root, commit string) (map[string]string, error)

Types

type BaseMode

type BaseMode string
const (
	BaseWorkingTree BaseMode = "working-tree"
	BaseMergeBase   BaseMode = "merge-base"
	BaseTwoDot      BaseMode = "two-dot"
)

type Change

type Change struct {
	Path      string
	Status    string
	Lines     []LineRange
	BaseLines []LineRange
}

func (Change) BaseLineNumbers

func (c Change) BaseLineNumbers() []int

func (Change) LineNumbers

func (c Change) LineNumbers() []int

func (Change) Touches

func (c Change) Touches(start, end int) bool

func (Change) WholeFile

func (c Change) WholeFile() bool

type ChurnStat

type ChurnStat struct {
	Commits      int   `json:"commits"`
	LinesChanged int   `json:"linesChanged"`
	LastUnix     int64 `json:"lastUnix"`
}

ChurnStat is one file's recent change activity.

type LineRange

type LineRange struct {
	Start int
	End   int
}

func (LineRange) Contains

func (r LineRange) Contains(line int) bool

type Options

type Options struct {
	Root             string
	Base             string
	IncludeUntracked bool
}

type Result

type Result struct {
	Changes    []Change
	BaseMode   BaseMode
	BaseCommit string
	Note       string
}

func Changes

func Changes(ctx context.Context, opts Options) (Result, error)

Jump to

Keyboard shortcuts

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