Help us shape the future of Go! Take the 2026 Go Developer Survey

git

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAmbiguousBase = errors.New("comparison has no unique merge base")
View Source
var ErrInvalidLimits = errors.New("invalid Git input limits")
View Source
var ErrInvalidRevision = errors.New("invalid commit revision")
View Source
var ErrLimit = errors.New("git input limit exceeded")
View Source
var ErrMalformedDiff = errors.New("malformed Git diff")
View Source
var ErrMissingSource = errors.New("work item source is unavailable")

Functions

This section is empty.

Types

type Limits

type Limits struct {
	MaxPatchBytes     int
	MaxBlobBytes      int
	MaxTotalBlobBytes int
	MaxItems          int
}

Limits cap encoded patch bytes, each source blob, and the number of work items. Zero fields select finite defaults.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository reads Git objects and working tree state using pure Go.

func NewRepository

func NewRepository(dir string, limits Limits) (*Repository, error)

func (*Repository) Compare

func (r *Repository) Compare(ctx context.Context, base, head string) (Result, error)

Compare resolves an immutable committed range and returns no partial result on command, parser, or resource-limit failure.

func (*Repository) CompareUncommitted added in v0.5.2

func (r *Repository) CompareUncommitted(ctx context.Context) (Result, error)

CompareUncommitted inspects unstaged, staged, and untracked changes in the working tree.

type Result

type Result struct {
	Revisions Revisions
	Items     []WorkItem
	Skips     []Skip
	// contains filtered or unexported fields
}

Result holds a complete comparison. Sources are copied out on request.

func (Result) Source

func (r Result) Source(item WorkItem) ([]byte, error)

Source returns a copy of the committed file side used by an item.

type Revisions

type Revisions struct {
	Base      string
	Head      string
	MergeBase string
}

Revisions contains only verified immutable commit IDs.

type Side

type Side string

Side identifies the committed file whose changed lines carry the anchor.

const (
	Left  Side = "LEFT"
	Right Side = "RIGHT"
)

type Skip

type Skip struct {
	OldPath string
	NewPath string
	Reason  SkipReason
}

type SkipReason

type SkipReason string
const (
	SkipBinary     SkipReason = "binary"
	SkipNonRegular SkipReason = "non_regular"
	SkipNoLines    SkipReason = "no_changed_lines"
)

type WorkItem

type WorkItem struct {
	ID        string
	OldPath   string
	NewPath   string
	Path      string
	Side      Side
	StartLine int
	EndLine   int
	Hunk      int
	// contains filtered or unexported fields
}

WorkItem anchors one contiguous changed span in a committed file side.

Jump to

Keyboard shortcuts

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