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 Landed ¶ added in v0.133.0
Landed says whether the commit sha's changes are already on base by content: merging it into base changes nothing (`git merge-tree --write-tree`, git 2.38+, gives base's own tree). It finds a branch whose work reached the default branch by a squash merge or inside another branch's batch, which `git cherry` cannot (the patch ids differ). An error (an older git, a conflict, an unknown commit) is "not known", never "landed". Kept per pair of commits.
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"`
// Subject is its last commit's subject line (the release plan's row
// title for a pushed branch with no pull request).
Subject string `json:"subject,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.