Back to godoc.org
github.com/abhinav/restack

Package restack

v0.3.1
Latest Go to latest
Published: Apr 28, 2020 | License: MIT | Module: github.com/abhinav/restack

Index

Package Files

Constants

const Version = "0.3.1"

Version is the version of restack currently being used.

Note that semantic versioning in this repository applies to the `restack` executable, not to its library components. These APIs may break at any time without warning.

type Branch

type Branch struct {
	Name string
	Hash string
}

Branch refers to a Git branch.

type Edit

type Edit struct {
	// Editor to use for the file.
	Editor string

	// Path to file containing initial rebase instruction list.
	Path string

	Restacker Restacker

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

Edit implements the "restack edit" command.

func (*Edit) Run

func (e *Edit) Run(ctx context.Context) error

Run runs the "restack edit" command.

type Git

type Git interface {
	ListBranches(ctx context.Context) ([]Branch, error)

	// RebaseHeadName returns the name of the branch being rebased or an empty
	// string if we're not in the middle of a rebase.
	RebaseHeadName(ctx context.Context) (string, error)
}

Git provides access to git commands.

type GitRestacker

type GitRestacker struct {
	// Controls access to Git commands.
	//
	// This field is required.
	Git Git
}

GitRestacker restacks instruction lists using the provided Git instance.

func (*GitRestacker) Restack

func (r *GitRestacker) Restack(ctx context.Context, req *Request) error

Restack process the provided instruction list.

type Request

type Request struct {
	// Name of the git remote. If set, an opt-in section that pushes restacked
	// branches to this remote will also be generated.
	//
	// This field is optional.
	RemoteName string

	// Input and output instruction lists.
	From io.Reader
	To   io.Writer
}

Request is a request to process a rebase instruction list.

type Restacker

type Restacker interface {
	Restack(context.Context, *Request) error
}

Restacker processes the rebase instruction list.

type Setup

type Setup struct {
	PrintScript bool

	Stdout io.Writer
	Stderr io.Writer
}

Setup is the "restack setup" command.

func (*Setup) Run

func (s *Setup) Run(ctx context.Context) error

Run runs the setup command.

type SystemGit

type SystemGit struct {
	Getenv func(string) string
}

SystemGit uses the global `git` command to perform git operations.

func (*SystemGit) ListBranches

func (*SystemGit) ListBranches(ctx context.Context) ([]Branch, error)

ListBranches implements Git.ListBranches.

func (*SystemGit) RebaseHeadName

func (g *SystemGit) RebaseHeadName(ctx context.Context) (string, error)

RebaseHeadName implements Git.RebaseHeadName.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier