Help us shape the future of Go! Take the 2026 Go Developer Survey

git

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package git provides Git operations for the gwq application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Git

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

Git provides Git command operations.

func New

func New(workDir string) *Git

New creates a new Git instance.

func NewFromCwd

func NewFromCwd() (*Git, error)

NewFromCwd creates a new Git instance using the current working directory.

func (*Git) AddWorktree

func (g *Git) AddWorktree(path, branch string, createBranch bool) error

AddWorktree creates a new worktree.

func (*Git) AddWorktreeFromBase added in v0.0.4

func (g *Git) AddWorktreeFromBase(path, branch, baseBranch string) error

AddWorktreeFromBase creates a new worktree with a branch from a specific base branch.

func (*Git) DeleteBranch

func (g *Git) DeleteBranch(branch string, force bool) error

DeleteBranch deletes a branch.

func (*Git) GetRecentCommits

func (g *Git) GetRecentCommits(path string, limit int) ([]models.CommitInfo, error)

GetRecentCommits returns recent commits for a specific path.

func (*Git) GetRepositoryName

func (g *Git) GetRepositoryName() (string, error)

GetRepositoryName returns the name of the repository.

func (*Git) GetRepositoryPath

func (g *Git) GetRepositoryPath() (string, error)

GetRepositoryPath returns the root path of the git repository.

func (*Git) GetRepositoryURL

func (g *Git) GetRepositoryURL() (string, error)

GetRepositoryURL returns the remote origin URL of the repository.

func (*Git) ListBranches

func (g *Git) ListBranches(includeRemote bool) ([]models.Branch, error)

ListBranches returns a list of all branches.

func (*Git) ListWorktrees

func (g *Git) ListWorktrees() ([]models.Worktree, error)

ListWorktrees returns a list of all worktrees in the repository.

func (*Git) PruneWorktrees

func (g *Git) PruneWorktrees() error

PruneWorktrees removes worktree information for deleted directories.

func (*Git) RemoveWorktree

func (g *Git) RemoveWorktree(path string, force bool) error

RemoveWorktree removes a worktree.

func (*Git) Run added in v0.0.3

func (g *Git) Run(args ...string) (string, error)

Run is an alias for RunCommand maintained for backward compatibility. New code should prefer using RunCommand for clarity.

func (*Git) RunCommand

func (g *Git) RunCommand(args ...string) (string, error)

RunCommand executes a git command with the provided arguments and returns the output. This is the primary public interface for running arbitrary git commands. The command is executed in the Git instance's working directory if set. Returns the command output as a string, or an error if the command fails.

func (*Git) RunWithContext added in v0.0.3

func (g *Git) RunWithContext(ctx context.Context, args ...string) (string, error)

RunWithContext executes a git command with context support for cancellation and timeout. The command will be terminated if the context is cancelled or times out. This is useful for implementing timeouts or graceful shutdowns. Returns the command output as a string, or an error if the command fails or is cancelled.

Jump to

Keyboard shortcuts

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