Documentation
¶
Overview ¶
Package worktrees audits the git worktrees of one repository: which are clean, which carry work the integration branch does not, and which could be removed. See docs/runtime/worktrees-tool-design.md.
It runs git and nothing else. What only the room knows, whether atrium made a worktree and whether a card is still using it, comes in through Input.Judge, so the git half is tested against a real repository and the card half where the cards are.
Index ¶
Constants ¶
const ( // CallBound is how long a whole audit may take, and CommandBound how long any one git command of it may. CallBound = 60 * time.Second CommandBound = 20 * time.Second // MaxLines is how many worktrees an answer lists. The rest are counted in the trailer and not measured. MaxLines = 100 )
const ( ReasonNotAtriums = "not atrium's" ReasonMain = "main checkout" ReasonProtected = "protected branch" ReasonDirty = "dirty" ReasonUnlanded = "unlanded" ReasonLocked = "locked" ReasonNotListed = "not a worktree" ReasonUnknown = "unknown" )
Reasons a worktree is kept, as they read on a line.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Input ¶
type Input struct {
// Repo is a directory inside any checkout or worktree of the repository.
Repo string
// Prefix and Paths narrow the answer. Both together are refused.
Prefix string
Paths []string
// Judge answers for the room. Nil reads as every worktree being atrium's, with nothing after.
Judge func(path string) Judgment
// Runner runs git. Nil takes a runner bounded at CommandBound.
Runner *gitsync.Runner
}
Input is one audit.
type Judgment ¶
type Judgment struct {
// Atriums is whether atrium made the worktree, by the ledger rule.
Atriums bool
// Later are the reasons that come after the git ones: a card in use, and reclaimBlock's sentence.
Later []string
}
Judgment is what the room says of a worktree path.
type Line ¶
type Line struct {
Path string `json:"path"`
Branch string `json:"branch"`
// Missing is a directory git lists that is gone.
Missing bool `json:"missing,omitempty"`
Main bool `json:"main,omitempty"`
Locked bool `json:"locked,omitempty"`
Detached bool `json:"detached,omitempty"`
// Dirty is the count of status lines, less an untracked root BRIEF.md or REPORT.md, which are Flags.
Dirty int `json:"dirty"`
Flags []string `json:"flags,omitempty"`
// Landed is the weakest evidence, ancestry, patch or subject. Empty when Unlanded is not 0 or nothing was measured.
Landed string `json:"landed,omitempty"`
Unlanded int `json:"unlanded"`
Newest string `json:"newest,omitempty"`
Subject string `json:"subject,omitempty"`
// Unknown is why git could not answer, and the line is never removable.
Unknown string `json:"unknown,omitempty"`
Removable bool `json:"removable"`
Prune bool `json:"prune,omitempty"`
Keep []string `json:"keep,omitempty"`
// NotListed is a path that was asked for and git does not list.
NotListed bool `json:"not_listed,omitempty"`
// contains filtered or unexported fields
}
Line is one worktree, with the fields the line prints.
type Refusal ¶
type Refusal struct{ Why string }
Refusal is an audit that was not run, and the sentence that says why.
type Result ¶
type Result struct {
Ref string `json:"ref"`
RefSHA string `json:"ref_sha"`
// From is `hub` or `local`.
From string `json:"from"`
Total int `json:"total"`
Lines []Line `json:"lines"`
// More is how many worktrees were left out past MaxLines.
More int `json:"more,omitempty"`
Unknown int `json:"unknown,omitempty"`
FirstUnknown string `json:"first_unknown,omitempty"`
Text string `json:"text"`
}
Result is an audit. Text is the answer as the tool says it.
type Update ¶
type Update struct {
Path string `json:"path"`
Branch string `json:"branch"`
Done string `json:"done,omitempty"`
Skipped string `json:"skipped,omitempty"`
}
Update is one worktree's outcome. Skipped says why nothing was done.