ghstack

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 14 Imported by: 1 module, 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 ghstack implements the stack ports on top of GitHub's gh-stack extension. Stack metadata is read directly from the extension's <git-dir>/gh-stack file (documented, schema version 1); every mutation goes through `gh stack` commands so the file is never written by us.

Index

Constants

View Source
const FileName = "gh-stack"

FileName is the gh-stack metadata file inside the git directory.

View Source
const SchemaVersion = 1

SchemaVersion is the only version this adapter understands.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend implements the stack ports via gh-stack.

func New

func New(r exec.Runner, g *git.Client, opts ...Option) *Backend

New returns a Backend that runs gh through r.

func (*Backend) Abort

func (b *Backend) Abort(ctx context.Context, repo git.Repo) error

Abort abandons an interrupted rebase and restores every branch.

func (*Backend) AddTop

func (b *Backend) AddTop(ctx context.Context, repo git.Repo, name string) error

AddTop runs `gh stack add <name>` without committing (we commit natively).

func (*Backend) Continue

func (b *Backend) Continue(ctx context.Context, repo git.Repo) error

Continue resumes an interrupted rebase.

func (*Backend) InitStack

func (b *Backend) InitStack(ctx context.Context, repo git.Repo, trunk string, branches []string) error

InitStack runs `gh stack init --base <trunk> <branches...>`.

func (*Backend) Load

func (b *Backend) Load(_ context.Context, repo git.Repo) (*stack.Graph, error)

Load implements stack.Metadata. gh stack keeps its file per worktree (<git-dir>/gh-stack), so this reads the current worktree's file first, then the main checkout's and every linked worktree's, and merges them so one view covers everything checked out on the machine. A missing file means no stacks; it never runs gh. A branch that appears in two files keeps its first stack.

func (*Backend) Preflight

func (b *Backend) Preflight(ctx context.Context) error

Preflight verifies gh and the gh-stack extension are installed. The result is cached per Backend for the life of the process.

func (*Backend) Restack

func (b *Backend) Restack(ctx context.Context, repo git.Repo, scope stack.Scope) error

Restack runs the local-only form of `gh stack rebase`: no fetch and no trunk update. The bottom branch is never rebased onto trunk in this mode.

func (*Backend) Submit

Submit runs `gh stack submit`. Non-interactive runs use --auto and are captured; interactive runs hand gh-stack the real terminal so its own PR editor can open.

func (*Backend) Sync

func (b *Backend) Sync(ctx context.Context, repo git.Repo, o stack.SyncOptions) (stack.SyncResult, error)

Sync runs `gh stack sync [--prune]`.

type Option

type Option func(*Backend)

Option configures a Backend.

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput relays the output of long running gh stack commands (submit, sync) to w as it is produced instead of only returning it afterwards. The CLI sets this to stderr; the MCP server never does.

Jump to

Keyboard shortcuts

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