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
- func Add(ctx context.Context, branch string, options AddOptions) error
- func CurrentBranch(ctx context.Context) (string, error)
- func Edit(ctx context.Context, branch string, options EditOptions) error
- func ExitCode(err error) int
- func Gh(ctx context.Context, args ...string) error
- func Git(ctx context.Context, args ...string) error
- func GitOutput(ctx context.Context, args ...string) (string, error)
- func InStack(ctx context.Context) (bool, error)
- func Save(ctx context.Context, options SaveOptions) error
- func Ship(ctx context.Context, options ShipOptions) error
- func Stack(ctx context.Context, args ...string) error
- func WithGhPath(parent context.Context, path string) context.Context
- func WithGitPath(parent context.Context, path string) context.Context
- type AddOptions
- type CommitOptions
- type EditOptions
- type RemoteOptions
- type SaveOptions
- type ShipOptions
Constants ¶
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 ¶
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 ¶
ExitCode returns the exit code of the process err came from, or -1 when err was not produced by a child process
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 WithGhPath ¶
WithGhPath returns a context resolving the gh binary to path
Types ¶
type AddOptions ¶
type AddOptions struct {
CommitOptions
Base string
}
type CommitOptions ¶
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
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
}