git

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MergeConflictError

type MergeConflictError struct {
	Branch  string
	Message string
}

MergeConflictError is returned when a merge results in conflicts

func (*MergeConflictError) Error

func (e *MergeConflictError) Error() string

type Repo

type Repo struct {
	*git.Repository
	// contains filtered or unexported fields
}

Repo wraps a git repository with helpful methods

func OpenRepo

func OpenRepo(path string) (*Repo, error)

OpenRepo opens a git repository in the current or specified directory

func (*Repo) BranchExists

func (r *Repo) BranchExists(name string) bool

BranchExists checks if a branch exists (local or remote)

func (*Repo) Checkout

func (r *Repo) Checkout(ref string) error

Checkout checks out a branch or commit

func (*Repo) CreateBranch

func (r *Repo) CreateBranch(name string, fromRef string) error

CreateBranch creates a new branch

func (*Repo) CurrentBranch

func (r *Repo) CurrentBranch() (string, error)

CurrentBranch returns the name of the current branch

func (*Repo) CurrentCommitSHA

func (r *Repo) CurrentCommitSHA() (string, error)

CurrentCommitSHA returns the SHA of the current commit

func (*Repo) DeleteBranch

func (r *Repo) DeleteBranch(name string, force bool) error

DeleteBranch deletes a branch

func (*Repo) DeleteRemoteBranch

func (r *Repo) DeleteRemoteBranch(remoteName string, branchName string) error

DeleteRemoteBranch deletes a branch from remote

func (*Repo) HasUncommittedChanges

func (r *Repo) HasUncommittedChanges(branch string) (bool, error)

HasUncommittedChanges checks if a branch has uncommitted changes Note: This requires executing git commands as go-git doesn't support this well

func (*Repo) IsDetachedHead

func (r *Repo) IsDetachedHead() bool

IsDetachedHead checks if HEAD is in detached state

func (*Repo) Merge

func (r *Repo) Merge(branch string, message string) error

Merge merges a branch into the current branch with an optional message Note: This uses git command as go-git's merge support is limited

func (*Repo) MergeAbort

func (r *Repo) MergeAbort() error

MergeAbort aborts an in-progress merge

func (*Repo) MergeSquash

func (r *Repo) MergeSquash(branch string, message string) error

MergeSquash squash merges a branch into the current branch

func (*Repo) Pull

func (r *Repo) Pull(remoteName string, branchName string) error

Pull pulls changes from remote

func (*Repo) Push

func (r *Repo) Push(remoteName string, branchName string, force bool) error

Push pushes changes to remote Uses force-with-lease for safety

func (*Repo) UserEmail

func (r *Repo) UserEmail() (string, error)

UserEmail returns the configured git user email

func (*Repo) UserName

func (r *Repo) UserName() (string, error)

UserName returns the configured git user name

Jump to

Keyboard shortcuts

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