Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInterruptReorder = errors.Sentinel("interrupt reorder")
ErrInterruptReorder is an error that is returned by Cmd implementations when the reorder operation should be suspended (and later resumed with --continue, --skip, or --reorder).
Functions ¶
func WriteContinuation ¶ added in v0.0.17
func WriteContinuation(repo *git.Repo, continuation *Continuation) error
WriteContinuation writes a continuation to the state file. If a nil continuation is passed, the state file is deleted.
Types ¶
type Cmd ¶
type Cmd interface { // Execute executes the command. Execute(ctx *Context) error // String returns a string representation of the command. // The string representation must be parseable such that // ParseCmd(cmd.String()) == cmd. String() string }
func CreatePlan ¶ added in v0.0.17
CreatePlan creates a reorder plan for the stack rooted at rootBranch.
type Context ¶
type Context struct { // Repo is the repository the reorder operation is being performed on. Repo *git.Repo // DB is the av database of the repository. DB meta.DB // State is the current state of the reorder operation. State *State // Output is the output stream to write interactive messages to. // Commands should write to this stream instead of stdout/stderr. Output io.Writer }
Context is the context of a reorder operation. Commands can use the context to access the current state of the reorder.
type Continuation ¶
type Continuation struct {
State *State
}
func ReadContinuation ¶ added in v0.0.17
func ReadContinuation(repo *git.Repo) (*Continuation, error)
ReadContinuation reads a continuation from the state file. Returns the raw error returned by os.Open if the file couldn't be opened. Use os.IsNotExist to check if the continuation doesn't exist.
func Reorder ¶
func Reorder(ctx Context) (*Continuation, error)
Reorder executes a reorder. If the reorder couldn't be completed (due to a conflict), a continuation is returned. If the reorder was completed successfully, a nil continuation and nil error is returned.
type DeleteBranchCmd ¶ added in v0.0.17
type DeleteBranchCmd struct { Name string // If true, delete the branch from Git as well as from the internal database. // If false, only delete the branch metadata from the internal database. DeleteGitRef bool }
DeleteBranchCmd is a command that deletes a branch. This is for internal use only to clean up branches that were removed from a re-order operation.
func (DeleteBranchCmd) Execute ¶ added in v0.0.17
func (d DeleteBranchCmd) Execute(ctx *Context) error
func (DeleteBranchCmd) String ¶ added in v0.0.17
func (d DeleteBranchCmd) String() string
type ErrInvalidCmd ¶
func (ErrInvalidCmd) Error ¶
func (e ErrInvalidCmd) Error() string
type PickCmd ¶
PickCmd is a command that picks a commit from the history and applies it on top of the current HEAD.
type StackBranchCmd ¶
type StackBranchCmd struct { // The name of the branch to create. Name string // The name of the parent branch. If not specified, the previous branch in // the reorder stack is used (or an error is raised if there is no previous // branch). // Mutually exclusive with --trunk. Parent string // The name of the trunk branch. // Mutually exclusive with --parent. // The branch can be rooted at a given commit by appending "@<commit>" to the // branch name. Trunk string // An optional comment to include in the reorder plan for this command. Comment string }
StackBranchCmd is a command to create a new branch in a stack.
stack-branch <branch-name> [--parent <parent-branch-name>] [--trunk <trunk-branch-name>]
func (StackBranchCmd) Execute ¶
func (b StackBranchCmd) Execute(ctx *Context) error
func (StackBranchCmd) String ¶
func (b StackBranchCmd) String() string
type State ¶
type State struct { // The current HEAD of the reorder operation. Head string `json:"head"` // The name of the current branch in the reorder operation. Branch string `json:"branch"` // The sequence of commands to be executed. // NOTE: we handle marshalling/unmarshalling in the MarshalJSON/UnmarshalJSON methods. Commands []Cmd `json:"-"` }
State is the state of a reorder operation. It is meant to be serializable to allow the user to continue/abort a reorder operation if there is a conflict.