steps

package
v7.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 19 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeletePreviousRunState

func DeletePreviousRunState()

DeletePreviousRunState deletes the previous run state from disk

func Run

func Run(runState *RunState)

Run runs the Git Town command described by the given state nolint: gocyclo

func SaveRunState

func SaveRunState(runState *RunState)

SaveRunState saves the run state to disk

Types

type AbortMergeBranchStep

type AbortMergeBranchStep struct {
	NoOpStep
}

AbortMergeBranchStep aborts the current merge conflict.

func (*AbortMergeBranchStep) Run

func (step *AbortMergeBranchStep) Run() error

Run executes this step.

type AbortRebaseBranchStep

type AbortRebaseBranchStep struct {
	NoOpStep
}

AbortRebaseBranchStep represents aborting on ongoing merge conflict. This step is used in the abort scripts for Git Town commands.

func (*AbortRebaseBranchStep) Run

func (step *AbortRebaseBranchStep) Run() error

Run executes this step.

type AddToPerennialBranches

type AddToPerennialBranches struct {
	NoOpStep
	BranchName string
}

AddToPerennialBranches adds the branch with the given name as a perennial branch

func (*AddToPerennialBranches) CreateUndoStepBeforeRun

func (step *AddToPerennialBranches) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*AddToPerennialBranches) Run

func (step *AddToPerennialBranches) Run() error

Run executes this step.

type ChangeDirectoryStep

type ChangeDirectoryStep struct {
	NoOpStep
	Directory string
}

ChangeDirectoryStep changes the current working directory.

func (*ChangeDirectoryStep) CreateUndoStepBeforeRun

func (step *ChangeDirectoryStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*ChangeDirectoryStep) Run

func (step *ChangeDirectoryStep) Run() error

Run executes this step.

type CheckoutBranchStep

type CheckoutBranchStep struct {
	NoOpStep
	BranchName string
}

CheckoutBranchStep checks out a new branch.

func (*CheckoutBranchStep) CreateUndoStepBeforeRun

func (step *CheckoutBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*CheckoutBranchStep) Run

func (step *CheckoutBranchStep) Run() error

Run executes this step.

type CommitOpenChangesStep

type CommitOpenChangesStep struct {
	NoOpStep
}

CommitOpenChangesStep commits all open changes as a new commit. It does not ask the user for a commit message, but chooses one automatically.

func (*CommitOpenChangesStep) CreateUndoStepBeforeRun

func (step *CommitOpenChangesStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*CommitOpenChangesStep) Run

func (step *CommitOpenChangesStep) Run() error

Run executes this step.

type ContinueMergeBranchStep

type ContinueMergeBranchStep struct {
	NoOpStep
}

ContinueMergeBranchStep finishes an ongoing merge conflict assuming all conflicts have been resolved by the user.

func (*ContinueMergeBranchStep) CreateAbortStep

func (step *ContinueMergeBranchStep) CreateAbortStep() Step

CreateAbortStep returns the abort step for this step.

func (*ContinueMergeBranchStep) CreateContinueStep

func (step *ContinueMergeBranchStep) CreateContinueStep() Step

CreateContinueStep returns the continue step for this step.

func (*ContinueMergeBranchStep) Run

func (step *ContinueMergeBranchStep) Run() error

Run executes this step.

type ContinueRebaseBranchStep

type ContinueRebaseBranchStep struct {
	NoOpStep
}

ContinueRebaseBranchStep finishes an ongoing rebase operation assuming all conflicts have been resolved by the user.

func (*ContinueRebaseBranchStep) CreateAbortStep

func (step *ContinueRebaseBranchStep) CreateAbortStep() Step

CreateAbortStep returns the abort step for this step.

func (*ContinueRebaseBranchStep) CreateContinueStep

func (step *ContinueRebaseBranchStep) CreateContinueStep() Step

CreateContinueStep returns the continue step for this step.

func (*ContinueRebaseBranchStep) Run

func (step *ContinueRebaseBranchStep) Run() error

Run executes this step.

type CreateBranchStep

type CreateBranchStep struct {
	NoOpStep
	BranchName    string
	StartingPoint string
}

CreateBranchStep creates a new branch but leaves the current branch unchanged.

func (*CreateBranchStep) CreateUndoStepBeforeRun

func (step *CreateBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*CreateBranchStep) Run

func (step *CreateBranchStep) Run() error

Run executes this step.

type CreatePullRequestStep

type CreatePullRequestStep struct {
	NoOpStep
	BranchName string
}

CreatePullRequestStep creates a new pull request for the current branch.

func (*CreatePullRequestStep) Run

func (step *CreatePullRequestStep) Run() error

Run executes this step.

type CreateRemoteBranchStep

type CreateRemoteBranchStep struct {
	NoOpStep
	BranchName string
	Sha        string
}

CreateRemoteBranchStep pushes the current branch up to origin.

func (*CreateRemoteBranchStep) Run

func (step *CreateRemoteBranchStep) Run() error

Run executes this step.

type CreateTrackingBranchStep

type CreateTrackingBranchStep struct {
	NoOpStep
	BranchName string
}

CreateTrackingBranchStep pushes the current branch up to origin and marks it as tracking the current branch.

func (*CreateTrackingBranchStep) CreateUndoStepBeforeRun

func (step *CreateTrackingBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*CreateTrackingBranchStep) Run

func (step *CreateTrackingBranchStep) Run() error

Run executes this step.

type DeleteLocalBranchStep

type DeleteLocalBranchStep struct {
	NoOpStep
	BranchName string
	Force      bool
}

DeleteLocalBranchStep deletes the branch with the given name, optionally in a safe or unsafe way.

func (*DeleteLocalBranchStep) CreateUndoStepBeforeRun

func (step *DeleteLocalBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*DeleteLocalBranchStep) Run

func (step *DeleteLocalBranchStep) Run() error

Run executes this step.

type DeleteParentBranchStep

type DeleteParentBranchStep struct {
	NoOpStep
	BranchName string
}

DeleteParentBranchStep removes the parent branch entry in the Git Town configuration.

func (*DeleteParentBranchStep) CreateUndoStepBeforeRun

func (step *DeleteParentBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*DeleteParentBranchStep) Run

func (step *DeleteParentBranchStep) Run() error

Run executes this step.

type DeleteRemoteBranchStep

type DeleteRemoteBranchStep struct {
	NoOpStep
	BranchName string
	IsTracking bool
}

DeleteRemoteBranchStep deletes the current branch from the origin remote.

func (*DeleteRemoteBranchStep) CreateUndoStepBeforeRun

func (step *DeleteRemoteBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*DeleteRemoteBranchStep) Run

func (step *DeleteRemoteBranchStep) Run() error

Run executes this step.

type DiscardOpenChangesStep

type DiscardOpenChangesStep struct {
	NoOpStep
}

DiscardOpenChangesStep resets the branch to the last commit, discarding uncommitted changes.

func (*DiscardOpenChangesStep) Run

func (step *DiscardOpenChangesStep) Run() error

Run executes this step.

type DriverMergePullRequestStep

type DriverMergePullRequestStep struct {
	NoOpStep
	BranchName           string
	CommitMessage        string
	DefaultCommitMessage string
	// contains filtered or unexported fields
}

DriverMergePullRequestStep squash merges the branch with the given name into the current branch

func (*DriverMergePullRequestStep) CreateAbortStep

func (step *DriverMergePullRequestStep) CreateAbortStep() Step

CreateAbortStep returns the abort step for this step.

func (*DriverMergePullRequestStep) CreateUndoStepAfterRun

func (step *DriverMergePullRequestStep) CreateUndoStepAfterRun() Step

CreateUndoStepAfterRun returns the undo step for this step after it is run.

func (*DriverMergePullRequestStep) GetAutomaticAbortErrorMessage

func (step *DriverMergePullRequestStep) GetAutomaticAbortErrorMessage() string

GetAutomaticAbortErrorMessage returns the error message to display when this step cause the command to automatically abort.

func (*DriverMergePullRequestStep) Run

func (step *DriverMergePullRequestStep) Run() error

Run executes this step.

func (*DriverMergePullRequestStep) ShouldAutomaticallyAbortOnError

func (step *DriverMergePullRequestStep) ShouldAutomaticallyAbortOnError() bool

ShouldAutomaticallyAbortOnError returns whether this step should cause the command to automatically abort if it errors.

type EnsureHasShippableChangesStep

type EnsureHasShippableChangesStep struct {
	NoOpStep
	BranchName string
}

EnsureHasShippableChangesStep asserts that the branch has unique changes not on the main branch

func (*EnsureHasShippableChangesStep) GetAutomaticAbortErrorMessage

func (step *EnsureHasShippableChangesStep) GetAutomaticAbortErrorMessage() string

GetAutomaticAbortErrorMessage returns the error message to display when this step cause the command to automatically abort.

func (*EnsureHasShippableChangesStep) Run

Run executes this step.

func (*EnsureHasShippableChangesStep) ShouldAutomaticallyAbortOnError

func (step *EnsureHasShippableChangesStep) ShouldAutomaticallyAbortOnError() bool

ShouldAutomaticallyAbortOnError returns whether this step should cause the command to automatically abort if it errors.

type FetchUpstreamStep

type FetchUpstreamStep struct {
	NoOpStep
	BranchName string
}

FetchUpstreamStep brings the Git history of the local repository up to speed with activities that happened in the upstream remote.

func (*FetchUpstreamStep) Run

func (step *FetchUpstreamStep) Run() error

Run executes this step.

type JSONStep

type JSONStep struct {
	Step Step
}

JSONStep is used to store a step in JSON

func (*JSONStep) MarshalJSON

func (j *JSONStep) MarshalJSON() (b []byte, e error)

MarshalJSON marshals the step to JSON

func (*JSONStep) UnmarshalJSON

func (j *JSONStep) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the step from JSON nolint: gocyclo

type MergeBranchStep

type MergeBranchStep struct {
	NoOpStep
	BranchName string
}

MergeBranchStep merges the branch with the given name into the current branch

func (*MergeBranchStep) CreateAbortStep

func (step *MergeBranchStep) CreateAbortStep() Step

CreateAbortStep returns the abort step for this step.

func (*MergeBranchStep) CreateContinueStep

func (step *MergeBranchStep) CreateContinueStep() Step

CreateContinueStep returns the continue step for this step.

func (*MergeBranchStep) CreateUndoStepBeforeRun

func (step *MergeBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*MergeBranchStep) Run

func (step *MergeBranchStep) Run() error

Run executes this step.

type NoOpStep

type NoOpStep struct{}

NoOpStep does nothing. It is used for steps that have no undo or abort steps.

func (*NoOpStep) CreateAbortStep

func (step *NoOpStep) CreateAbortStep() Step

CreateAbortStep returns the abort step for this step.

func (*NoOpStep) CreateContinueStep

func (step *NoOpStep) CreateContinueStep() Step

CreateContinueStep returns the continue step for this step.

func (*NoOpStep) CreateUndoStepAfterRun

func (step *NoOpStep) CreateUndoStepAfterRun() Step

CreateUndoStepAfterRun returns the undo step for this step after it is run.

func (*NoOpStep) CreateUndoStepBeforeRun

func (step *NoOpStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*NoOpStep) GetAutomaticAbortErrorMessage

func (step *NoOpStep) GetAutomaticAbortErrorMessage() string

GetAutomaticAbortErrorMessage returns the error message to display when this step cause the command to automatically abort.

func (*NoOpStep) Run

func (step *NoOpStep) Run() error

Run executes this step.

func (*NoOpStep) ShouldAutomaticallyAbortOnError

func (step *NoOpStep) ShouldAutomaticallyAbortOnError() bool

ShouldAutomaticallyAbortOnError returns whether this step should cause the command to automatically abort if it errors.

type PreserveCheckoutHistoryStep

type PreserveCheckoutHistoryStep struct {
	NoOpStep
	InitialBranch                     string
	InitialPreviouslyCheckedOutBranch string
}

PreserveCheckoutHistoryStep does stuff

func (*PreserveCheckoutHistoryStep) Run

func (step *PreserveCheckoutHistoryStep) Run() error

Run executes this step.

type PullBranchStep

type PullBranchStep struct {
	NoOpStep
	BranchName string
}

PullBranchStep pulls the branch with the given name from the origin remote

func (*PullBranchStep) Run

func (step *PullBranchStep) Run() error

Run executes this step.

type PushBranchAfterCurrentBranchSteps

type PushBranchAfterCurrentBranchSteps struct {
	NoOpStep
}

PushBranchAfterCurrentBranchSteps is a mock step that is used in the undo process to push the branch after other steps have been undone.

type PushBranchStep

type PushBranchStep struct {
	NoOpStep
	BranchName string
	Force      bool
	Undoable   bool
}

PushBranchStep pushes the branch with the given name to the origin remote. Optionally with force.

func (*PushBranchStep) CreateUndoStepBeforeRun

func (step *PushBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*PushBranchStep) Run

func (step *PushBranchStep) Run() error

Run executes this step.

type PushTagsStep

type PushTagsStep struct {
	NoOpStep
}

PushTagsStep pushes newly created Git tags to the remote.

func (*PushTagsStep) Run

func (step *PushTagsStep) Run() error

Run executes this step.

type RebaseBranchStep

type RebaseBranchStep struct {
	NoOpStep
	BranchName string
}

RebaseBranchStep rebases the current branch against the branch with the given name.

func (*RebaseBranchStep) CreateAbortStep

func (step *RebaseBranchStep) CreateAbortStep() Step

CreateAbortStep returns the abort step for this step.

func (*RebaseBranchStep) CreateContinueStep

func (step *RebaseBranchStep) CreateContinueStep() Step

CreateContinueStep returns the continue step for this step.

func (*RebaseBranchStep) CreateUndoStepBeforeRun

func (step *RebaseBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*RebaseBranchStep) Run

func (step *RebaseBranchStep) Run() error

Run executes this step.

type RemoveFromPerennialBranches

type RemoveFromPerennialBranches struct {
	NoOpStep
	BranchName string
}

RemoveFromPerennialBranches removes the branch with the given name as a perennial branch

func (*RemoveFromPerennialBranches) CreateUndoStepBeforeRun

func (step *RemoveFromPerennialBranches) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*RemoveFromPerennialBranches) Run

func (step *RemoveFromPerennialBranches) Run() error

Run executes this step.

type ResetToShaStep

type ResetToShaStep struct {
	NoOpStep
	Hard bool
	Sha  string
}

ResetToShaStep undoes all commits on the current branch all the way until the given SHA.

func (*ResetToShaStep) Run

func (step *ResetToShaStep) Run() error

Run executes this step.

type RestoreOpenChangesStep

type RestoreOpenChangesStep struct {
	NoOpStep
}

RestoreOpenChangesStep restores stashed away changes into the workspace.

func (*RestoreOpenChangesStep) CreateUndoStepBeforeRun

func (step *RestoreOpenChangesStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*RestoreOpenChangesStep) Run

func (step *RestoreOpenChangesStep) Run() error

Run executes this step.

type RevertCommitStep

type RevertCommitStep struct {
	NoOpStep
	Sha string
}

RevertCommitStep reverts the commit with the given sha.

func (*RevertCommitStep) Run

func (step *RevertCommitStep) Run() error

Run executes this step.

type RunState

type RunState struct {
	AbortStepList StepList
	Command       string
	IsAbort       bool

	UnfinishedDetails *UnfinishedRunStateDetails
	RunStepList       StepList
	UndoStepList      StepList
	// contains filtered or unexported fields
}

RunState represents the current state of a Git Town command, including which operations are left to do, and how to undo what has ben done so far.

func LoadPreviousRunState

func LoadPreviousRunState() *RunState

LoadPreviousRunState loads the run state from disk if it exists or creates a new run state

func NewRunState

func NewRunState(command string, stepList StepList) *RunState

NewRunState returns a new run state

func (*RunState) AddPushBranchStepAfterCurrentBranchSteps

func (runState *RunState) AddPushBranchStepAfterCurrentBranchSteps()

AddPushBranchStepAfterCurrentBranchSteps inserts a PushBranchStep after all the steps for the current branch

func (*RunState) CreateAbortRunState

func (runState *RunState) CreateAbortRunState() (result RunState)

CreateAbortRunState returns a new runstate to be run to aborting and undoing the Git Town command represented by this runstate.

func (*RunState) CreateSkipRunState

func (runState *RunState) CreateSkipRunState() (result RunState)

CreateSkipRunState returns a new Runstate that skips operations for the current branch.

func (*RunState) CreateUndoRunState

func (runState *RunState) CreateUndoRunState() (result RunState)

CreateUndoRunState returns a new runstate to be run when undoing the Git Town command represented by this runstate.

func (*RunState) IsUnfinished

func (runState *RunState) IsUnfinished() bool

IsUnfinished returns whether or not the run state is unfinished

func (*RunState) MarkAsFinished

func (runState *RunState) MarkAsFinished()

MarkAsFinished updates the run state to be marked as finished

func (*RunState) MarkAsUnfinished

func (runState *RunState) MarkAsUnfinished()

MarkAsUnfinished updates the run state to be marked as unfinished and populates informational fields

func (*RunState) SkipCurrentBranchSteps

func (runState *RunState) SkipCurrentBranchSteps()

SkipCurrentBranchSteps removes the steps for the current branch from this run state.

type SetParentBranchStep

type SetParentBranchStep struct {
	NoOpStep
	BranchName       string
	ParentBranchName string
}

SetParentBranchStep registers the branch with the given name as a parent of the branch with the other given name.

func (*SetParentBranchStep) CreateUndoStepBeforeRun

func (step *SetParentBranchStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*SetParentBranchStep) Run

func (step *SetParentBranchStep) Run() error

Run executes this step.

type SkipCurrentBranchSteps

type SkipCurrentBranchSteps struct {
	NoOpStep
}

SkipCurrentBranchSteps is a mock step to be used instead of running another list of steps. This is used when ignoring the remaining steps for a particular branch.

type SquashMergeBranchStep

type SquashMergeBranchStep struct {
	NoOpStep
	BranchName    string
	CommitMessage string
}

SquashMergeBranchStep squash merges the branch with the given name into the current branch

func (*SquashMergeBranchStep) CreateAbortStep

func (step *SquashMergeBranchStep) CreateAbortStep() Step

CreateAbortStep returns the abort step for this step.

func (*SquashMergeBranchStep) CreateUndoStepAfterRun

func (step *SquashMergeBranchStep) CreateUndoStepAfterRun() Step

CreateUndoStepAfterRun returns the undo step for this step after it is run.

func (*SquashMergeBranchStep) GetAutomaticAbortErrorMessage

func (step *SquashMergeBranchStep) GetAutomaticAbortErrorMessage() string

GetAutomaticAbortErrorMessage returns the error message to display when this step cause the command to automatically abort.

func (*SquashMergeBranchStep) Run

func (step *SquashMergeBranchStep) Run() error

Run executes this step.

func (*SquashMergeBranchStep) ShouldAutomaticallyAbortOnError

func (step *SquashMergeBranchStep) ShouldAutomaticallyAbortOnError() bool

ShouldAutomaticallyAbortOnError returns whether this step should cause the command to automatically abort if it errors.

type StashOpenChangesStep

type StashOpenChangesStep struct {
	NoOpStep
}

StashOpenChangesStep stores all uncommitted changes on the Git stash.

func (*StashOpenChangesStep) CreateUndoStepBeforeRun

func (step *StashOpenChangesStep) CreateUndoStepBeforeRun() Step

CreateUndoStepBeforeRun returns the undo step for this step before it is run.

func (*StashOpenChangesStep) Run

func (step *StashOpenChangesStep) Run() error

Run executes this step.

type Step

type Step interface {
	CreateAbortStep() Step
	CreateContinueStep() Step
	CreateUndoStepBeforeRun() Step
	CreateUndoStepAfterRun() Step
	GetAutomaticAbortErrorMessage() string
	Run() error
	ShouldAutomaticallyAbortOnError() bool
}

Step represents a dedicated activity within a Git Town command. Git Town commands are comprised of a number of steps that need to be executed.

type StepList

type StepList struct {
	List []Step
}

StepList is a list of steps with convenience functions for adding and removing steps.

func GetSyncBranchSteps

func GetSyncBranchSteps(branchName string, pushBranch bool) (result StepList)

GetSyncBranchSteps returns the steps to sync the branch with the given name.

func (*StepList) Append

func (stepList *StepList) Append(step Step)

Append adds the given step to the end of this StepList.

func (*StepList) AppendList

func (stepList *StepList) AppendList(otherList StepList)

AppendList adds all elements of the given StepList to the end of this StepList.

func (*StepList) MarshalJSON

func (stepList *StepList) MarshalJSON() (b []byte, e error)

MarshalJSON marshals the step list to JSON

func (*StepList) Peek

func (stepList *StepList) Peek() (result Step)

Peek returns the first element of this StepList.

func (*StepList) Pop

func (stepList *StepList) Pop() (result Step)

Pop removes and returns the first element of this StepList.

func (*StepList) Prepend

func (stepList *StepList) Prepend(step Step)

Prepend adds the given step to the beginning of this StepList.

func (*StepList) PrependList

func (stepList *StepList) PrependList(otherList StepList)

PrependList adds all elements of the given StepList to the start of this StepList.

func (*StepList) UnmarshalJSON

func (stepList *StepList) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the step list from JSON

func (*StepList) Wrap

func (stepList *StepList) Wrap(options WrapOptions)

Wrap wraps the list with steps that change to the Git root directory or stash away open changes.

type UnfinishedRunStateDetails

type UnfinishedRunStateDetails struct {
	CanSkip   bool
	EndBranch string
	EndTime   time.Time
}

UnfinishedRunStateDetails has details about an unfinished run state

type WrapOptions

type WrapOptions struct {
	RunInGitRoot     bool
	StashOpenChanges bool
}

WrapOptions represents the options given to Wrap.

Jump to

Keyboard shortcuts

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