branches

package
v0.122.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func IsStale(b Branch, openPR bool, now time.Time) bool

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

func ParseAheadBehind(s string) (*int, *int)

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.

func List

func List(ctx context.Context, dir, def string) (Listing, error)

List reads dir's branches: local ones and origin's, compared with the default branch (def, else origin's HEAD, else main or master). Kept for a few seconds per directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL