clones

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: BSD-3-Clause Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clones builds the Diagnostics tab's clones view: the git clones and linked worktrees under one root, judged by go-gitsafe/gitsafe's clonestate used as a library. clonestate reads local facts only (it never fetches), at about five git processes per repository, so a Runner scans on its own goroutine and the snapshots only read its last answer. The cost is bounded three ways: four repositories at once, a timeout per repository, and clonestate's cache, which answers again from memory while the repository's HEAD, index, reflog, FETCH_HEAD and packed refs are unchanged and for at most its MaxAge.

Index

Constants

View Source
const CacheAge = 15 * time.Minute

CacheAge is the longest a clone's judgement is reused. It must exceed a pass (else the cache never answers: the entries of a pass are all older than the age when the next one reaches them), so a change to a tracked file of a clean clone is seen within this time.

View Source
const RefreshEvery = 10 * time.Minute

RefreshEvery is how often Run scans again. A tracked file edited in a clean clone touches none of the files the cache keys on, so the cache's MaxAge is what lets it turn dirty: the two are chosen together. Measured on the real workspace (13737 repositories and worktrees): a cold pass took 456 s at a load of about 70, so a period of a minute would keep git running without a pause; ten minutes leaves room.

View Source
const RepoTimeout = 10 * time.Second

RepoTimeout bounds the git work on one repository.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	Root    string // absolute
	Display string // how the user writes it
	Opt     clonestate.Options

	Scan func(ctx context.Context, root string, opt clonestate.Options) ([]clonestate.State, clonestate.Unread, error)
	Now  func() time.Time
}

Engine scans a root. Scan and Now are the seams a test replaces.

func New

func New(root, display string) *Engine

New is the production engine over root: clonestate's defaults (four workers, four directory levels), a per-repository timeout and a cache shared by every pass.

func (*Engine) View

func (e *Engine) View(ctx context.Context) *model.Clones

View scans now.

type Runner

type Runner struct {
	Eng *Engine
	// Every is the time between two passes; 0 means RefreshEvery.
	Every time.Duration
	// contains filtered or unexported fields
}

Runner keeps the latest view of an Engine.

func (*Runner) Latest

func (r *Runner) Latest() *model.Clones

Latest is the last view, nil before the first step ended.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context)

Run steps now and then every RefreshEvery until ctx ends. A pass never overlaps the next: the ticker drops a tick that finds the previous pass still running.

func (*Runner) Step

func (r *Runner) Step(ctx context.Context)

Step scans now.

type Source

type Source struct {
	Inner interface{ Snapshot() model.Snapshot }
	Run   *Runner
}

Source adds the latest clones view to the snapshots of an inner source.

func (Source) Snapshot

func (s Source) Snapshot() model.Snapshot

Snapshot is the inner snapshot with the Clones view attached.

Jump to

Keyboard shortcuts

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