list

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package list defines handlers that list the repository state.

Index

Constants

View Source
const (
	// IncludeMinimal includes only basic branch information.
	IncludeMinimal = 1 << iota

	// IncludeCommits includes a list of commits for each branch.
	IncludeCommits

	// IncludeChangeURL includes the URL for the associated change, if any.
	IncludeChangeURL

	// IncludePushStatus includes push status information for each branch
	// (e.g. ahead/behind counts).
	IncludePushStatus
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchItem

type BranchItem struct {
	// Name of the branch.
	Name string

	// Base branch onto which this branch is stacked.
	// Empty if this branch is trunk.
	Base string

	// Aboves lists branches that are stacked directly above this branch.
	Aboves []int

	Commits []git.CommitDetail // only if IncludeCommits is set

	// ChangeID is the ID of the associated change, if any.
	ChangeID   forge.ChangeID
	ChangeURL  string      // only if IncludeChangeURL is set
	PushStatus *PushStatus // only if IncludePushStatus is set

	// NeedsRestack indicates whether this branch needs to be restacked
	// on top of its base branch.
	NeedsRestack bool
}

BranchItem is a single branch in the log output.

type BranchesRequest

type BranchesRequest struct {
	// Branch is the name of the branch to start from.
	// By default, only branches that are part of this branch's stack
	// are included.
	//
	// If Options.All is set, this is ignored and all tracked branches
	Branch string // required

	Options *Options
	Include Include
}

BranchesRequest holds the parameters for the log command.

type BranchesResponse

type BranchesResponse struct {
	Branches []*BranchItem
	TrunkIdx int
}

BranchesResponse holds the result of the log handler.

type GitRepository

type GitRepository interface {
	RemoteURL(context.Context, string) (string, error)
	CommitAheadBehind(context.Context, string, string) (int, int, error)
	ListCommitsDetails(context.Context, git.CommitRange) iter.Seq2[git.CommitDetail, error]
}

GitRepository lists operations from git.Repository that we need for the log handler.

type Handler

type Handler struct {
	Log        *silog.Logger   // required
	Repository GitRepository   // required
	Store      Store           // required
	Service    Service         // required
	Forges     *forge.Registry // required
}

Handler implements the business logic for git-spice's log commands.

func (*Handler) ListBranches

func (h *Handler) ListBranches(ctx context.Context, req *BranchesRequest) (*BranchesResponse, error)

ListBranches logs the branches in the repository according to the request parameters.

type Include

type Include int

Include specifies what additional information to include in the response.

type Options

type Options struct {
	All bool `short:"a" long:"all" config:"log.all" help:"Show all tracked branches, not just the current stack."`
}

Options holds command line options for the log command.

type PushStatus

type PushStatus struct {
	// Ahead and Behind specify the number of commits
	// that the branch is ahead or behind its remote tracking branch.
	Ahead, Behind int

	// NeedsPush indicates whether the branch has commits
	// that need to be pushed to the remote.
	//
	// This will be false if Ahead and Behind are both zero.
	NeedsPush bool
}

PushStatus contains push-related information if the branch has been pushed to a remote.

type Service

type Service interface {
	BranchGraph(context.Context, *spice.BranchGraphOptions) (*spice.BranchGraph, error)
	CheckRestacked(context.Context, string) (git.Hash, error)
}

Service provides access to git-spice's higher-level operations.

type Store

type Store interface {
	Remote() (string, error)
	Trunk() string
}

Store provides access to git-spice's state store.

Jump to

Keyboard shortcuts

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