undoer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUndoNotSupported = errors.New("git undo not supported")

Functions

This section is empty.

Types

type AddUndoer

type AddUndoer struct {
	// contains filtered or unexported fields
}

AddUndoer handles undoing git add operations.

func (*AddUndoer) GetUndoCommands added in v0.2.0

func (a *AddUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the add operation.

type BackUndoer added in v0.2.0

type BackUndoer struct {
	// contains filtered or unexported fields
}

BackUndoer handles undoing git checkout and git switch operations by returning to the previous branch.

func (*BackUndoer) GetUndoCommands added in v0.2.0

func (b *BackUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the checkout/switch operation.

type BranchUndoer

type BranchUndoer struct {
	// contains filtered or unexported fields
}

BranchUndoer handles undoing git branch operations.

func (*BranchUndoer) GetUndoCommands added in v0.2.0

func (b *BranchUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the branch creation.

type CheckoutUndoer

type CheckoutUndoer struct {
	// contains filtered or unexported fields
}

CheckoutUndoer handles undoing git checkout operations.

func (*CheckoutUndoer) GetUndoCommands added in v0.2.0

func (c *CheckoutUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the checkout operation.

type CherryPickUndoer added in v0.2.0

type CherryPickUndoer struct {
	// contains filtered or unexported fields
}

CherryPickUndoer handles undoing git cherry-pick operations.

func (*CherryPickUndoer) GetUndoCommands added in v0.2.0

func (c *CherryPickUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the cherry-pick operation.

type CleanUndoer added in v0.2.0

type CleanUndoer struct {
	// contains filtered or unexported fields
}

CleanUndoer handles undoing git clean operations. Note: git clean removes untracked files, so undo requires proactive backup.

func (*CleanUndoer) GetUndoCommands added in v0.2.0

func (c *CleanUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the clean operation.

type CommandDetails

type CommandDetails struct {
	FullCommand string   // git commit -m "message"
	Command     string   // git
	SubCommand  string   // commit
	Args        []string // []string{"-m", "message"}
}

CommandDetails represents parsed git command details.

type CommitUndoer

type CommitUndoer struct {
	// contains filtered or unexported fields
}

CommitUndoer handles undoing git commit operations.

func (*CommitUndoer) GetUndoCommands added in v0.2.0

func (c *CommitUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the commit.

type GitExec

type GitExec interface {
	GitRun(subCmd string, args ...string) error
	GitOutput(subCmd string, args ...string) (string, error)
}

GitExec represents an interface for executing git commands.

type InvalidUndoer

type InvalidUndoer struct {
	// contains filtered or unexported fields
}

InvalidUndoer represents an undoer for commands that cannot be parsed or are not supported.

func (*InvalidUndoer) GetUndoCommands added in v0.2.0

func (i *InvalidUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands implements the Undoer interface.

type MergeUndoer

type MergeUndoer struct {
	// contains filtered or unexported fields
}

MergeUndoer handles undoing git merge operations.

func (*MergeUndoer) GetUndoCommands added in v0.2.0

func (m *MergeUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the merge operation.

type MvUndoer added in v0.2.0

type MvUndoer struct {
	// contains filtered or unexported fields
}

MvUndoer handles undoing git mv operations.

func (*MvUndoer) GetUndoCommands added in v0.2.0

func (m *MvUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the mv operation.

type ResetUndoer added in v0.2.0

type ResetUndoer struct {
	// contains filtered or unexported fields
}

ResetUndoer handles undoing git reset operations.

func (*ResetUndoer) GetUndoCommands added in v0.2.0

func (r *ResetUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the reset operation.

type RestoreUndoer added in v0.2.0

type RestoreUndoer struct {
	// contains filtered or unexported fields
}

RestoreUndoer handles undoing git restore operations.

func (*RestoreUndoer) GetUndoCommands added in v0.2.0

func (r *RestoreUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the restore operation.

type RevertUndoer added in v0.2.0

type RevertUndoer struct {
	// contains filtered or unexported fields
}

RevertUndoer handles undoing git revert operations.

func (*RevertUndoer) GetUndoCommands added in v0.2.0

func (r *RevertUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the revert operation.

type RmUndoer added in v0.2.0

type RmUndoer struct {
	// contains filtered or unexported fields
}

RmUndoer handles undoing git rm operations.

func (*RmUndoer) GetUndoCommands added in v0.2.0

func (r *RmUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the rm operation.

type StashUndoer

type StashUndoer struct {
	// contains filtered or unexported fields
}

StashUndoer handles undoing git stash operations.

func (*StashUndoer) GetUndoCommands added in v0.2.0

func (s *StashUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the stash operation.

type SwitchUndoer added in v0.2.0

type SwitchUndoer struct {
	// contains filtered or unexported fields
}

SwitchUndoer handles undoing git switch operations.

func (*SwitchUndoer) GetUndoCommands added in v0.2.0

func (s *SwitchUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the switch operation.

type TagUndoer added in v0.2.0

type TagUndoer struct {
	// contains filtered or unexported fields
}

TagUndoer handles undoing git tag operations.

func (*TagUndoer) GetUndoCommands added in v0.2.0

func (t *TagUndoer) GetUndoCommands() ([]*UndoCommand, error)

GetUndoCommands returns the commands that would undo the tag creation.

type UndoCommand

type UndoCommand struct {
	// Command is the actual git command string to execute
	Command string
	// Warnings contains any warnings that should be shown to the user
	Warnings []string
	// Description is a human-readable description of what the command will do
	Description string
	// contains filtered or unexported fields
}

UndoCommand represents a command that can undo a git operation.

func NewUndoCommand

func NewUndoCommand(git GitExec, cmdStr string, description string, warnings ...string) *UndoCommand

NewUndoCommand creates a new UndoCommand instance.

func (*UndoCommand) Exec

func (cmd *UndoCommand) Exec() error

Exec executes the undo command and returns its success status.

type Undoer

type Undoer interface {
	// GetUndoCommands returns the commands that would undo the operation
	// Some operations may require multiple git commands to undo properly
	GetUndoCommands() ([]*UndoCommand, error)
}

Undoer represents an interface for undoing git commands.

func New

func New(cmdStr string, gitExec GitExec) Undoer

New returns the appropriate Undoer implementation for a git command.

func NewBack added in v0.2.0

func NewBack(cmdStr string, gitExec GitExec) Undoer

NewBack returns the appropriate Undoer implementation for git-back (checkout/switch undo).

Jump to

Keyboard shortcuts

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