undoer

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 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) GetUndoCommand

func (a *AddUndoer) GetUndoCommand() (*UndoCommand, error)

GetUndoCommand returns the command that would undo the add operation.

type BranchUndoer

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

BranchUndoer handles undoing git branch operations.

func (*BranchUndoer) GetUndoCommand

func (b *BranchUndoer) GetUndoCommand() (*UndoCommand, error)

GetUndoCommand returns the command that would undo the branch creation.

type CheckoutUndoer

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

CheckoutUndoer handles undoing git checkout operations.

func (*CheckoutUndoer) GetUndoCommand

func (c *CheckoutUndoer) GetUndoCommand() (*UndoCommand, error)

GetUndoCommand returns the command that would undo the checkout 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) GetUndoCommand

func (c *CommitUndoer) GetUndoCommand() (*UndoCommand, error)

GetUndoCommand returns the command that would undo the commit.

type GitExec

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

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) GetUndoCommand

func (i *InvalidUndoer) GetUndoCommand() (*UndoCommand, error)

type MergeUndoer

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

MergeUndoer handles undoing git merge operations.

func (*MergeUndoer) GetUndoCommand

func (m *MergeUndoer) GetUndoCommand() (*UndoCommand, error)

GetUndoCommand returns the command that would undo the merge operation.

type StashUndoer

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

StashUndoer handles undoing git stash operations.

func (*StashUndoer) GetUndoCommand

func (s *StashUndoer) GetUndoCommand() (*UndoCommand, error)

GetUndoCommand returns the command that would undo the stash operation.

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

func (*UndoCommand) Exec

func (cmd *UndoCommand) Exec() error

Exec executes the undo command and returns its success status.

type Undoer

type Undoer interface {
	// GetUndoCommand returns the command that would undo the operation
	GetUndoCommand() (*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.

Jump to

Keyboard shortcuts

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