stack

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Update added in v1.1.11

func Update(bareDir string, fn func(*Stack)) error

Update performs a locked read-modify-write cycle on branches.json. The lock prevents concurrent willow commands from corrupting the file.

Types

type Stack

type Stack struct {
	Parents map[string]string `json:"parents"` // branch → parent
}

Stack tracks parent-child relationships between branches for stacked PRs. Stored as branches.json in the bare repo directory.

func Load

func Load(bareDir string) *Stack

Load reads the stack from branches.json. Returns an empty stack if the file doesn't exist.

func (*Stack) Children

func (s *Stack) Children(branch string) []string

Children returns direct children of a branch (branches whose parent is this branch).

func (*Stack) Descendants

func (s *Stack) Descendants(branch string) []string

Descendants returns all transitive children of a branch.

func (*Stack) IsEmpty

func (s *Stack) IsEmpty() bool

IsEmpty returns true if no branches are tracked.

func (*Stack) IsTracked

func (s *Stack) IsTracked(branch string) bool

func (*Stack) Parent

func (s *Stack) Parent(branch string) string

func (*Stack) Remove

func (s *Stack) Remove(branch string)

Remove deletes a branch from the stack and re-parents its children to the removed branch's parent.

func (*Stack) Roots

func (s *Stack) Roots() []string

Roots returns branches whose parent is NOT itself a tracked branch. These are the entry points of stacks (e.g., branches based on "main").

func (*Stack) Save

func (s *Stack) Save(bareDir string) error

Save writes the stack to branches.json. Removes the file if the stack is empty.

func (*Stack) SetParent

func (s *Stack) SetParent(branch, parent string)

func (*Stack) SubtreeSort

func (s *Stack) SubtreeSort(root string) []string

SubtreeSort returns a branch and its descendants in topological order.

func (*Stack) TopoSort

func (s *Stack) TopoSort() []string

TopoSort returns all tracked branches in topological order (parents before children).

func (*Stack) TreeLines

func (s *Stack) TreeLines(branchSet map[string]bool) []TreeLine

TreeLines generates display lines with tree-drawing characters for the given set of branches. Only branches present in the provided set are included.

type TreeLine

type TreeLine struct {
	Branch string
	Prefix string // e.g., "├─ ", "│  └─ ", ""
	Depth  int
}

TreeLine represents a branch with its tree-drawing prefix for display.

Jump to

Keyboard shortcuts

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