git

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(dir string, patterns ...string) error

Add stages files for commit

func Checkout

func Checkout(dir string, ref string) error

Checkout switches to the specified branch

func Commit

func Commit(dir string, message string) error

Commit creates a commit with the given message

func CreateBranch

func CreateBranch(dir string, name string) error

CreateBranch creates a new branch

func CreateWorktree

func CreateWorktree(repoDir string, branch string, worktreeDir string) error

CreateWorktree creates a new git worktree

func CurrentBranch

func CurrentBranch(dir string) (string, error)

CurrentBranch returns the current branch name

func GetVersion

func GetVersion() (string, error)

GetVersion returns the git version

func Init

func Init(dir string) error

Init initializes a new git repository

func IsGitInstalled

func IsGitInstalled() bool

IsGitInstalled checks if git is available in PATH

func IsRepo

func IsRepo(dir string) bool

IsRepo checks if a directory is a git repository

func SetupTestConfig

func SetupTestConfig(dir string) error

SetupTestConfig configures a repo with test defaults

Types

type Git

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

Git represents a git repository

func CloneRepo

func CloneRepo(source, dest string) (*Git, error)

CloneRepo clones a repository (for testing remote operations)

func CreateTestRepo

func CreateTestRepo(dir string, files map[string]string) (*Git, error)

CreateTestRepo creates a git repository with initial content

func New

func New(dir string) *Git

New creates a new Git instance for the given directory

func SetupTestRepo

func SetupTestRepo(dir string) (*Git, error)

SetupTestRepo configures a repo with test defaults

func (*Git) Add

func (g *Git) Add(patterns ...string) error

Add stages files for commit

func (*Git) AddCommit

func (g *Git) AddCommit(message string) error

AddCommit stages all changes and commits with the given message

func (*Git) AddRemote

func (g *Git) AddRemote(name, url string) error

AddRemote adds a new remote

func (*Git) Checkout

func (g *Git) Checkout(ref string) error

Checkout switches to the specified branch

func (*Git) Commit

func (g *Git) Commit(message string) error

Commit creates a commit with the given message

func (*Git) CreateBranch

func (g *Git) CreateBranch(name string) error

CreateBranch creates a new branch

func (*Git) CreateBranchWithChanges

func (g *Git) CreateBranchWithChanges(branch string, changes map[string]string) error

CreateBranchWithChanges creates a new branch and makes changes

func (*Git) CreateWorktree

func (g *Git) CreateWorktree(path, branch string) error

CreateWorktree creates a new git worktree

func (*Git) CurrentBranch

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

CurrentBranch returns the current branch name

func (*Git) GetConfig

func (g *Git) GetConfig(key string) (string, error)

GetConfig gets a git configuration value

func (*Git) GetRootDir

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

GetRootDir returns the root directory of the git repository

func (*Git) HasUncommittedChanges

func (g *Git) HasUncommittedChanges() (bool, error)

HasUncommittedChanges checks if there are uncommitted changes

func (*Git) ListRemotes

func (g *Git) ListRemotes() ([]Remote, error)

ListRemotes returns all configured remotes

func (*Git) ListWorktrees

func (g *Git) ListWorktrees() ([]string, error)

ListWorktrees returns a list of all worktrees

func (*Git) PruneWorktrees

func (g *Git) PruneWorktrees() error

PruneWorktrees removes references to deleted worktrees

func (*Git) Pull

func (g *Git) Pull(remote, branch string) error

Pull pulls changes from a remote

func (*Git) Push

func (g *Git) Push(remote, branch string) error

Push pushes changes to a remote

func (*Git) RemoveRemote

func (g *Git) RemoveRemote(name string) error

RemoveRemote removes a remote

func (*Git) RemoveWorktree

func (g *Git) RemoveWorktree(name string) error

RemoveWorktree removes a git worktree

func (*Git) SetConfig

func (g *Git) SetConfig(key, value string) error

SetConfig sets a git configuration value

func (*Git) SetUser

func (g *Git) SetUser(name, email string) error

SetUser sets the user name and email for the repository

func (*Git) Status

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

Status returns the current git status

type Remote

type Remote struct {
	Name string
	URL  string
}

Remote represents a git remote

Jump to

Keyboard shortcuts

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