git

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MainBranch   = "main"
	MasterBranch = "master"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

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

func NewRepository

func NewRepository(path string) (*Repository, error)

func (*Repository) BranchExists

func (r *Repository) BranchExists(branch string) (bool, error)

BranchExists checks if a branch exists locally

func (*Repository) CreateWorktree

func (r *Repository) CreateWorktree(path, branch string) error

func (*Repository) ExecuteGitCommand

func (r *Repository) ExecuteGitCommand(args ...string) error

ExecuteGitCommand executes a git command in the repository directory

func (*Repository) GetMainWorktreePath

func (r *Repository) GetMainWorktreePath() (string, error)

GetMainWorktreePath returns the path to the main worktree (original repository) This is useful when running commands from within a worktree

func (*Repository) GetRemoteBranches

func (r *Repository) GetRemoteBranches(branch string) (map[string]string, error)

GetRemoteBranches returns a map of remote branches by remote name

func (*Repository) GetRepositoryName added in v1.0.0

func (r *Repository) GetRepositoryName() string

GetRepositoryName returns the name of the repository

func (*Repository) GetWorktrees

func (r *Repository) GetWorktrees() ([]Worktree, error)

func (*Repository) Path

func (r *Repository) Path() string

func (*Repository) RemoveWorktree

func (r *Repository) RemoveWorktree(path string, force bool) error

func (*Repository) ResolveBranch

func (r *Repository) ResolveBranch(branch string) (resolvedBranch string, isRemote bool, err error)

ResolveBranch resolves a branch name following git's behavior: 1. Check if branch exists locally 2. If not, check remote branches 3. If multiple remotes have the branch, return an error

type Worktree

type Worktree struct {
	Path   string
	Branch string
	HEAD   string
	IsMain bool // True if this is the main/root worktree
}

func (*Worktree) CompletionName added in v1.0.0

func (w *Worktree) CompletionName(repoName string) string

CompletionName returns the name to display for shell completion.

Format: <worktreeName>@<commit-ish>[(root worktree)]

Examples:

  • Root worktree: "giselle@fix-nodes(root worktree)"
  • Matching names: "develop" (when worktree dir and branch both = "develop")
  • Different names: "feature-awesome@feature/awesome"
  • Full path match: "feature/new-top-page" (when path ends with branch name)

func (*Worktree) IsMainWorktree added in v1.0.0

func (w *Worktree) IsMainWorktree(mainWorktreePath string) bool

IsMainWorktree returns true if this is the main/root worktree

func (*Worktree) Name

func (w *Worktree) Name() string

func (*Worktree) String

func (w *Worktree) String() string

Jump to

Keyboard shortcuts

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