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

annotate

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Line

type Line struct {
	Text         string
	Version      VersionInfo
	BelowHorizon bool
}

Line represents an annotated line of a file, with the text and the version that last changed it.

BelowHorizon marks a line whose origin lies at or below the structural horizon of the store (draft-fossil-horizon-00 §5.5): the walk reached a parent the store does not hold because it lies below the horizon, so the line is reported as originating at the horizon, and Version is the horizon's check-in rather than the line's origin.

func Annotate

func Annotate(r *repo.Repo, opts Options) ([]Line, error)

Annotate attributes each line of a file to the commit that last changed it. It walks the primary parent chain from StartRID, pushing line attributions back to the earliest ancestor that contains the same line.

func AnnotateContext added in v0.17.0

func AnnotateContext(ctx context.Context, r *repo.Repo, opts Options) ([]Line, error)

AnnotateContext is Annotate under ctx, which bounds the walk and any demand fetch it makes.

type Options

type Options struct {
	FilePath  string          // pathname of the file to annotate
	StartRID  libfossil.FslID // checkin to start from (tip)
	Limit     int             // max ancestors to walk (0 = unlimited)
	OriginRID libfossil.FslID // stop at this checkin (0 = none)
	// Cache, when set, serves the walk in place of the one Annotate makes
	// for itself, so a caller's longer-lived cache carries over between
	// calls. The caller keeps its entries current.
	Cache *content.Cache
	// Fetch, when set, is asked for the payloads of a version the walk
	// reads below a content horizon and the store does not hold, a version
	// at a time, so that only what the walk reads is fetched
	// (draft-fossil-horizon-00 §4.4). At most FetchLimit names are asked
	// for; past that, or with no Fetch, the walk stops at the horizon.
	Fetch      func(ctx context.Context, names []string) error
	FetchLimit int
}

Options controls the annotate operation.

type VersionInfo

type VersionInfo struct {
	UUID string
	User string
	Date time.Time
}

VersionInfo identifies the commit that last changed a line.

Jump to

Keyboard shortcuts

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