stack

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 7 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 stack orchestrates sequences of gh-stack commands.

Nothing here reimplements gh stack. Every exported function is a fixed list of git and gh stack invocations with stdio wired straight through, so the underlying tools own all output, prompting, and exit codes.

Index

Constants

View Source
const NotInStackCode = 2

NotInStackCode is the code gh stack exits with outside of a stack

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, branch string, options AddOptions) error

Add puts a new layer on top of the stack, creating the stack when there isn't one yet.

gh stack add [-A|-u] [-m <message>] <branch>

Or, outside of a stack:

gh stack init [--base <base>] <branch>
git add -A|-u
git commit -m <message>

func CurrentBranch

func CurrentBranch(ctx context.Context) (string, error)

CurrentBranch returns the name of the currently checked out branch

func Edit

func Edit(ctx context.Context, branch string, options EditOptions) error

Edit commits work to a lower layer of the stack and returns to the branch it started on.

gh stack checkout <branch>
git add -A|-u
git commit -m <message>
gh stack rebase --upstack
gh stack checkout <original branch>
gh stack push

Uncommitted changes travel with the checkout, so staging them beforehand is equivalent to staging them here.

func ExitCode

func ExitCode(err error) int

ExitCode returns the exit code of the process err came from, or -1 when err was not produced by a child process

func Gh

func Gh(ctx context.Context, args ...string) error

Gh runs gh with args

func Git

func Git(ctx context.Context, args ...string) error

Git runs git with args

func GitOutput

func GitOutput(ctx context.Context, args ...string) (string, error)

GitOutput runs git with args and returns its trimmed standard output

func InStack

func InStack(ctx context.Context) (bool, error)

InStack reports whether the current branch belongs to a stack

func Save

func Save(ctx context.Context, options SaveOptions) error

Save commits the current work and propagates it through the stack.

git add -A|-u
git commit -m <message>
gh stack rebase --upstack
gh stack push

func Ship

func Ship(ctx context.Context, options ShipOptions) error

Ship syncs the stack with the remote and opens or updates its pull requests.

gh stack sync [--prune]
gh stack submit --auto [--open]

submit always runs with --auto because a bare submit opens a full screen editor when attached to a terminal.

func Stack

func Stack(ctx context.Context, args ...string) error

Stack runs `gh stack` with args

func WithGhPath

func WithGhPath(parent context.Context, path string) context.Context

WithGhPath returns a context resolving the gh binary to path

func WithGitPath

func WithGitPath(parent context.Context, path string) context.Context

WithGitPath returns a context resolving the git binary to path

Types

type AddOptions

type AddOptions struct {
	CommitOptions
	Base string
}

type CommitOptions

type CommitOptions struct {
	All     bool
	Message string
	Update  bool
}

CommitOptions describes how work in the tree becomes a commit.

The flags mirror `gh stack add`: All stages everything including untracked files, Update stages tracked files only.

func (CommitOptions) AddArgs

func (o CommitOptions) AddArgs(branch string) (args []string)

AddArgs returns the `gh stack add` flags equivalent to o, followed by branch

func (CommitOptions) Commit

func (o CommitOptions) Commit(ctx context.Context) error

Commit stages the tree when All or Update is set and creates a commit when Message is non-empty. A commit is never created without a message.

type EditOptions

type EditOptions struct {
	CommitOptions
	RemoteOptions
	NoPush bool
}

type RemoteOptions

type RemoteOptions struct {
	Remote string
}

RemoteOptions describes the remote gh stack operates against

func (RemoteOptions) Args

func (o RemoteOptions) Args(args ...string) []string

Args returns args with the remote appended when one was specified

type SaveOptions

type SaveOptions struct {
	CommitOptions
	RemoteOptions
	NoPush bool
}

type ShipOptions

type ShipOptions struct {
	RemoteOptions
	NoSync bool
	Open   bool
	Prune  bool
}

Jump to

Keyboard shortcuts

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