git

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(path string, branch string, createBranch bool) error

Add is a package-level wrapper for backward compatibility

func BranchExists

func BranchExists(branch string) (bool, error)

BranchExists is a package-level wrapper for backward compatibility

func BranchToSuffix

func BranchToSuffix(branch string) string

BranchToSuffix converts a branch name to a directory suffix e.g., "feature/hoge" -> "feature-hoge"

func FetchBranch

func FetchBranch(branch string) error

FetchBranch is a package-level wrapper for backward compatibility

func GetMainWorktreePath

func GetMainWorktreePath() (string, error)

GetMainWorktreePath is a package-level wrapper for backward compatibility

func GetRepoName

func GetRepoName() (string, error)

GetRepoName is a package-level wrapper for backward compatibility

func GetRepoRoot

func GetRepoRoot() (string, error)

GetRepoRoot is a package-level wrapper for backward compatibility

func ListBranches

func ListBranches() ([]string, error)

ListBranches is a package-level wrapper for backward compatibility

func ParseWorktreeIdentifier

func ParseWorktreeIdentifier(identifier string, repoName string) string

ParseWorktreeIdentifier parses various forms of worktree identifier and returns the matching worktree if found Supported formats:

  • branch name: "feature/hoge"
  • suffix: "feature-hoge"
  • full dir name: "ex-repo-feature-hoge"
  • full path: "/path/to/ex-repo-feature-hoge"

func RemoteBranchExists

func RemoteBranchExists(branch string) (bool, error)

RemoteBranchExists is a package-level wrapper for backward compatibility

func Remove

func Remove(path string, force bool) error

Remove is a package-level wrapper for backward compatibility

func WorktreeDirName

func WorktreeDirName(repoName, branch string) string

WorktreeDirName generates just the directory name for a worktree

func WorktreePath

func WorktreePath(repoName, branch string) (string, error)

WorktreePath is a package-level wrapper for backward compatibility

Types

type Manager added in v0.2.0

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

Manager manages git operations with dependency injection

func NewManager added in v0.2.0

func NewManager(executor shell.Executor) *Manager

NewManager creates a new Manager with the given executor

func (*Manager) Add added in v0.2.0

func (m *Manager) Add(path string, branch string, createBranch bool) error

Add creates a new worktree

func (*Manager) BranchExists added in v0.2.0

func (m *Manager) BranchExists(branch string) (bool, error)

BranchExists checks if a branch exists

func (*Manager) Exists added in v0.2.0

func (m *Manager) Exists(pathOrBranch string) (*Worktree, error)

Exists checks if a worktree exists for the given path or branch

func (*Manager) FetchBranch added in v0.2.0

func (m *Manager) FetchBranch(branch string) error

FetchBranch fetches a branch from origin

func (*Manager) FindWorktree added in v0.2.0

func (m *Manager) FindWorktree(identifier string) (*Worktree, error)

FindWorktree finds a worktree by various identifier formats

func (*Manager) GetMainWorktreePath added in v0.2.0

func (m *Manager) GetMainWorktreePath() (string, error)

GetMainWorktreePath returns the path to the main (bare) worktree

func (*Manager) GetRepoName added in v0.2.0

func (m *Manager) GetRepoName() (string, error)

GetRepoName returns the name of the repository (directory name)

func (*Manager) GetRepoRoot added in v0.2.0

func (m *Manager) GetRepoRoot() (string, error)

GetRepoRoot returns the root directory of the git repository

func (*Manager) List added in v0.2.0

func (m *Manager) List() ([]Worktree, error)

List returns all worktrees for the current repository

func (*Manager) ListBranches added in v0.2.0

func (m *Manager) ListBranches() ([]string, error)

ListBranches returns all local and remote branches

func (*Manager) RemoteBranchExists added in v0.2.0

func (m *Manager) RemoteBranchExists(branch string) (bool, error)

RemoteBranchExists checks if a remote branch exists

func (*Manager) Remove added in v0.2.0

func (m *Manager) Remove(path string, force bool) error

Remove removes a worktree

func (*Manager) WorktreePath added in v0.2.0

func (m *Manager) WorktreePath(repoName, branch string) (string, error)

WorktreePath generates the worktree directory path e.g., for repo "ex-repo" and branch "feature/hoge" -> "../ex-repo-feature-hoge"

type Worktree

type Worktree struct {
	Path   string
	Branch string
	Commit string
	IsMain bool
}

Worktree represents a git worktree

func Exists

func Exists(pathOrBranch string) (*Worktree, error)

Exists is a package-level wrapper for backward compatibility

func FindWorktree

func FindWorktree(identifier string) (*Worktree, error)

FindWorktree is a package-level wrapper for backward compatibility

func List

func List() ([]Worktree, error)

List is a package-level wrapper for backward compatibility

Jump to

Keyboard shortcuts

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