git

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package git provides git repository operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchExists

func BranchExists(mainRepoPath, branchName string) (bool, error)

BranchExists checks if a branch exists in the repository.

func CheckoutBranch

func CheckoutBranch(repoPath, branchName string) error

CheckoutBranch checks out a branch in the specified repository.

func CheckoutExistingBranch

func CheckoutExistingBranch(mainRepoPath, worktreePath, branchName string) error

CheckoutExistingBranch creates a worktree for an existing branch at the specified path.

func CloneRepository

func CloneRepository(workspacePath, repoURL string) error

CloneRepository clones a git repository into the specified workspace path.

func CloneRepositoryWithOutput

func CloneRepositoryWithOutput(workspacePath, repoURL, repoName string) error

CloneRepositoryWithOutput clones a repository with detailed output and error handling.

func CreateWorktree

func CreateWorktree(mainRepoPath, worktreePath, branchName string) error

CreateWorktree creates a new git worktree with a new branch at the specified path.

func DeleteBranch

func DeleteBranch(mainRepoPath, branchName string) error

DeleteBranch force deletes a branch from the repository.

func FetchRemote

func FetchRemote(repoPath string) error

FetchRemote fetches the latest changes from the origin remote.

func GetAheadBehind

func GetAheadBehind(repoPath string) (ahead, behind int, hasUpstream bool, err error)

GetAheadBehind returns how many commits the branch is ahead/behind its upstream.

func GetAllBranches

func GetAllBranches(mainRepoPath string) ([]string, error)

GetAllBranches returns a list of all local branch names in the repository.

func GetBranchLastCommit

func GetBranchLastCommit(mainRepoPath, branchName string) (relativeTime, author string, err error)

GetBranchLastCommit returns the relative time and author of the last commit on a branch.

func GetCurrentBranch

func GetCurrentBranch(repoPath string) (string, error)

GetCurrentBranch returns the name of the currently checked out branch.

func GetDefaultBranch

func GetDefaultBranch(repoPath string) (string, error)

GetDefaultBranch returns the default branch name for the repository.

func GetDiffWithColor

func GetDiffWithColor(repoPath string, staged bool) (string, error)

func GetLastFetchTime

func GetLastFetchTime(repoPath string) (time.Time, error)

GetLastFetchTime returns when the repository was last fetched.

func GetMainRepoFromWorktree

func GetMainRepoFromWorktree(worktreePath string) (string, error)

GetMainRepoFromWorktree returns the path to the main repository for a given worktree.

func GetModifiedFiles

func GetModifiedFiles(repoPath string) ([]string, error)

GetModifiedFiles returns a list of modified file paths.

func GetUnpushedCommitCount

func GetUnpushedCommitCount(repoPath, branchName string) (int, error)

GetUnpushedCommitCount returns the number of commits not pushed to origin.

func HasDifftastic

func HasDifftastic() bool

func HasUncommittedChanges

func HasUncommittedChanges(repoPath string) (hasChanges bool, count int, err error)

HasUncommittedChanges checks if the repository has uncommitted changes.

func HasUnpushedCommits

func HasUnpushedCommits(repoPath, branchName string) (bool, error)

HasUnpushedCommits checks if the branch has commits not pushed to origin.

func IsBranchCheckedOut

func IsBranchCheckedOut(mainRepoPath, branchName string) (checkedOut bool, location string, err error)

IsBranchCheckedOut checks if a branch is currently checked out in any worktree.

func IsWorktree

func IsWorktree(path string) (bool, error)

IsWorktree checks if the given path is a git worktree (not a regular clone).

func MatchesBranchPattern

func MatchesBranchPattern(branchName, pattern string) bool

MatchesBranchPattern checks if a branch name matches a glob pattern.

func NeedsFetch

func NeedsFetch(repoPath string, threshold time.Duration) (bool, time.Duration, error)

NeedsFetch checks if the repository needs to be fetched.

func PruneWorktrees

func PruneWorktrees(mainRepoPath string) error

PruneWorktrees removes stale worktree entries from the repository.

func PullDefaultBranch

func PullDefaultBranch(repoPath string) error

PullDefaultBranch pulls the latest changes from the default branch.

func RemoveWorktree

func RemoveWorktree(mainRepoPath, worktreePath string) error

RemoveWorktree removes a git worktree from the repository.

func ShouldIgnoreBranch

func ShouldIgnoreBranch(branchName string, patterns []string) bool

ShouldIgnoreBranch checks if a branch should be ignored based on a list of patterns.

Types

type RepoStatusInfo

type RepoStatusInfo struct {
	Branch           string
	HasUncommitted   bool
	UncommittedCount int
	AheadCount       int
	BehindCount      int
	HasUpstream      bool
	LastFetch        time.Time
	LastCommit       string
	LastAuthor       string
	Error            error
}

RepoStatusInfo contains comprehensive status information about a git repository.

func GetFullRepoStatus

func GetFullRepoStatus(repoPath string) RepoStatusInfo

GetFullRepoStatus gathers all status info for a repository.

type WorktreeInfo

type WorktreeInfo struct {
	Path   string
	Branch string
	Commit string
}

WorktreeInfo contains information about a git worktree.

func ListWorktrees

func ListWorktrees(mainRepoPath string) ([]WorktreeInfo, error)

ListWorktrees returns a list of all worktrees associated with the repository.

Jump to

Keyboard shortcuts

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