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