Documentation
¶
Overview ¶
Package branches lists a repository's branches with what git knows of each for the session deck's Branches view (owner, 2026-10-12, translated: "seeing branches with statistics would also be interesting"): how far each is ahead of and behind the default branch, its last commit's time and author. Everything here is local git — `for-each-ref`, no network — read only while the view is shown, and kept a few seconds so a burst of reads runs git once.
Index ¶
Constants ¶
const StaleAfter = 30 * 24 * time.Hour
StaleAfter is how long without a commit makes a branch stale, when it also has no open pull request.
Variables ¶
This section is empty.
Functions ¶
func IsStale ¶
IsStale is the deck's stale mark: no commit in StaleAfter and no open pull request. The default branch is never stale; a branch with no known commit time is not called stale.
func ParseAheadBehind ¶
ParseAheadBehind reads "A B" — commits ahead of and behind the base, as %(ahead-behind:) and `rev-list --left-right --count base...ref` (behind first there, see countOne) print it; nil, nil when it is not two counts.
Types ¶
type Branch ¶
type Branch struct {
Name string `json:"name"`
Current bool `json:"current,omitempty"`
Default bool `json:"default,omitempty"`
Local bool `json:"local"`
// Remote is true when origin has it.
Remote bool `json:"remote"`
// Ahead and Behind count commits against the default branch (origin's
// copy when there is one); nil when not counted.
Ahead *int `json:"ahead,omitempty"`
Behind *int `json:"behind,omitempty"`
CommittedMS int64 `json:"committed_ms"`
Author string `json:"author,omitempty"`
SHA string `json:"sha,omitempty"`
}
Branch is one branch: local, on origin, or both, under its short name.
type Listing ¶
type Listing struct {
// Default is the default branch's name; Base the ref counted against
// ("origin/main", else "main"); both empty when neither is known.
Default string `json:"default,omitempty"`
Base string `json:"base,omitempty"`
Current string `json:"current,omitempty"`
Branches []Branch `json:"branches"`
}
Listing is a repository's branches and what they were compared with.