Documentation
¶
Overview ¶
Package peers is the read-only peer reader (itd-2609091416295622, spc-2609202056480020): given one checkout, which records do the other checkouts and branches sharing its git common dir hold that this tree does not, or hold in a different state?
Every collision on record between two sessions on one machine was a failure of visibility: the peer's record sat on the same disk, and the verb that collided answered "not found". This package makes the holding visible and changes nothing. It opens no file for writing, runs only read-only git commands under gitutil's isolated environment, takes no lock, and stamps nothing — the claim, the lease and the register are other records' work.
A PEER is one of two things, read through one reader:
- a linked worktree git lists for this repository (`git worktree list`), confirmed from its own `--git-common-dir` and read off its disk, so an uncommitted capture in it is seen;
- a local branch no worktree has checked out, read from the common dir with `git ls-tree`, so a paused branch is seen with no checkout at all.
A third source, the register (itd-2609150819440345), is where holdings live across accounts and machines. Its slot is the Sources list: this package ships with the two local sources only, and says so in every Report.
A holding is an id by FILENAME, under the issue ledger's status folders and the intent store's buckets, read by the same filename grammar the record resolver reads (recordid.FilenameNumRe). A record file is opened only for its title, through the guarded read (fsutil.ReadGuarded: no symlink followed, no device blocked on, a size cap), and a title that cannot be read leaves the id with no title rather than failing the listing.
This package is a library: it returns values and errors, and never prints.
Index ¶
Constants ¶
const ( SkipGone = "gone" SkipMerged = "merged" SkipEmbargo = "embargo store" )
Skip reasons: a spent peer contributes no rows and is counted instead. SkipEmbargo is the embargo store, which is not spent but private: its records are private security advisories' (adr-2610120558328615), so it is skipped unread and counted with no path.
const ( NotReadGitRefused = "git refused to answer for it: " NotReadSplit = "its ledger holds one id in two places" )
The starts of the not-read reasons a caller tells apart to choose a peer's repair: git would not answer for a worktree (most often a git file that points nowhere), and a ledger holds one id in two folders.
Variables ¶
var Sources = []Source{SourceWorktree, SourceBranch}
Sources is the set of sources this build reads. The register's slot is deliberately absent: a consumer reading a Report can tell "no peer holds it anywhere" from "no LOCAL peer holds it", which is all this build can say.
Functions ¶
func RecordsAt ¶ added in v0.15.1
RecordsAt is the record ids ref's tree holds, each with every file that claims it (its folder: open, resolved, wontfix, or an intent bucket; and its blob), read from the object store by filename, with no checkout and no network. It is the peers reader's own tree read, exported so a reservation decides which folder a record is in, and which blob it is, by the same reader.
Types ¶
type Kind ¶
type Kind string
Kind is which of the three diffs a row belongs to.
const ( // KindOpenThere is a record open in the peer and absent from every status // folder here: the peer captured something this tree has not seen. KindOpenThere Kind = "open-there" // KindTerminalThere is a record open here and resolved or won't-fixed in the // peer: the peer closed something this tree still thinks is open. KindTerminalThere Kind = "terminal-there" // KindDraftThere is an intent drafted in the peer and absent from every // bucket here. KindDraftThere Kind = "draft-there" )
type Location ¶
type Location struct {
Source Source `json:"source"`
Branch string `json:"branch,omitempty"`
Path string `json:"path,omitempty"`
Folder string `json:"folder"`
}
Location is where a live peer holds one record.
type Peer ¶
type Peer struct {
Source Source `json:"source"`
// Branch is the peer's short branch name; empty for a detached worktree.
Branch string `json:"branch,omitempty"`
// Path is the worktree's absolute path as git reports it; empty for a
// branch peer. A surface redacts it before it reaches a stream.
Path string `json:"path,omitempty"`
// NotRead is set, with the reason, when the peer was named and not read:
// git refused to answer for it, its common dir is not this checkout's, its
// ledger holds one id twice, or it holds no ledger at the committed layout.
// A peer that was not read carries no rows.
NotRead string `json:"not_read,omitempty"`
Rows []Row `json:"rows"`
// contains filtered or unexported fields
}
Peer is one live peer and what it holds.
func (Peer) NotReadShown ¶ added in v0.15.1
NotReadShown is p's not-read reason as a surface prints it, with no absolute local path in it: the peer's own directory as fsutil.DisplayPathsIn names it, HOME as ~, the checkout at repoRoot as ., and any other absolute path, such as where a broken git file points, by its last element alone (iss-2609281329007423). Every surface that prints a reason prints this form: the drain's refusal, the build's peers check and `abcd peers`.
type RecordAt ¶ added in v0.15.1
RecordAt is one file a ref's tree holds a record in: its folder and the object name of its blob.
type Report ¶
type Report struct {
// Sources is the set of sources read (see Sources).
Sources []Source `json:"sources"`
// DefaultRef is the ref a branch is judged merged into, empty when none
// could be resolved (then nothing is skipped as merged).
DefaultRef string `json:"default_ref,omitempty"`
Peers []Peer `json:"peers"`
Skipped []Skipped `json:"skipped"`
// contains filtered or unexported fields
}
Report is the whole picture for one checkout.
func Read ¶
Read returns the peer picture for the checkout at root, which is a checkout root (gitutil.CheckoutRoot's answer), not an arbitrary directory under it.
It fails only when this checkout itself cannot be read: git will not name its common dir, or its own record folders cannot be listed. Every fault in a PEER is that peer's NotRead, so one bad sibling never hides the others.
func Scan ¶
Scan is Read without the titles: the same peers, rows and locations, with no record file opened. It is for a caller that needs counts or a location — the board line, a not-found refusal — and should not pay a read per row.
func (Report) HeldHere ¶
HeldHere reports whether this checkout holds id in any folder of its family.
func (Report) Locate ¶
Locate returns every live, read peer that holds id, in any folder of its family. It is the not-found paths' question: a verb that cannot find a record here asks where it is before answering "not found".
func (Report) Unjudged ¶ added in v0.11.1
Unjudged returns the live peers that were named and not read for a reason that leaves what they hold unknown: git or the filesystem would not answer for them, or their ledger holds one id in two folders. Locate cannot see into these, so a caller that must not start past a peer's holding treats each as one. A peer of another repository, and one holding no records at the committed layout, hold nothing of this checkout's and are not returned.
type Row ¶
type Row struct {
ID string `json:"id"`
Kind Kind `json:"kind"`
// Folder is the folder that holds the record in the PEER: open, resolved,
// wontfix or drafts.
Folder string `json:"folder"`
// Title is the record's title, empty when the file could not be read or is
// malformed; the id is listed either way.
Title string `json:"title,omitempty"`
}
Row is one record a peer holds that this tree does not, or holds in another state.
type Skipped ¶
type Skipped struct {
Source Source `json:"source"`
Branch string `json:"branch,omitempty"`
Path string `json:"path,omitempty"`
Reason string `json:"reason"`
}
Skipped is a spent peer: its worktree directory is gone, or its branch is merged into the default branch (and, for a worktree, its record folders hold no uncommitted change).
type Source ¶
type Source string
Source names where a peer was read from.
const ( // SourceWorktree is a linked worktree sharing this checkout's common dir, // read off its disk. SourceWorktree Source = "worktree" // SourceBranch is a local branch no worktree has checked out, read from // the common dir. SourceBranch Source = "branch" // SourceRegister is the slot the register intent (itd-2609150819440345) // fills: holdings across accounts and machines. Nothing reads it yet. SourceRegister Source = "register" )