git

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 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 creates a new worktree

func BranchExists

func BranchExists(branch string) (bool, error)

BranchExists checks if a branch exists

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 fetches a branch from origin

func GetMainWorktreePath

func GetMainWorktreePath() (string, error)

GetMainWorktreePath returns the path to the main (bare) worktree

func GetRepoName

func GetRepoName() (string, error)

GetRepoName returns the name of the repository (directory name)

func GetRepoRoot

func GetRepoRoot() (string, error)

GetRepoRoot returns the root directory of the git repository

func ListBranches

func ListBranches() ([]string, error)

ListBranches returns all local and remote branches

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 checks if a remote branch exists

func Remove

func Remove(path string, force bool) error

Remove removes a worktree

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 generates the worktree directory path e.g., for repo "ex-repo" and branch "feature/hoge" -> "../ex-repo-feature-hoge"

Types

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 checks if a worktree exists for the given path or branch

func FindWorktree

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

FindWorktree finds a worktree by various identifier formats

func List

func List() ([]Worktree, error)

List returns all worktrees for the current repository

Jump to

Keyboard shortcuts

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