Documentation
¶
Overview ¶
Package git provides git repository operations.
Index ¶
- func BranchExists(mainRepoPath, branchName string) (bool, error)
- func CheckoutBranch(repoPath, branchName string) error
- func CheckoutExistingBranch(mainRepoPath, worktreePath, branchName string) error
- func CloneRepository(workspacePath, repoURL string) error
- func CloneRepositoryWithOutput(workspacePath, repoURL, repoName string) error
- func CreateWorktree(mainRepoPath, worktreePath, branchName string) error
- func DeleteBranch(mainRepoPath, branchName string) error
- func FetchRemote(repoPath string) error
- func GetAheadBehind(repoPath string) (ahead, behind int, hasUpstream bool, err error)
- func GetAllBranches(mainRepoPath string) ([]string, error)
- func GetBranchLastCommit(mainRepoPath, branchName string) (relativeTime, author string, err error)
- func GetCurrentBranch(repoPath string) (string, error)
- func GetDefaultBranch(repoPath string) (string, error)
- func GetDiffWithColor(repoPath string, staged bool) (string, error)
- func GetLastFetchTime(repoPath string) (time.Time, error)
- func GetMainRepoFromWorktree(worktreePath string) (string, error)
- func GetModifiedFiles(repoPath string) ([]string, error)
- func GetUnpushedCommitCount(repoPath, branchName string) (int, error)
- func HasDifftastic() bool
- func HasUncommittedChanges(repoPath string) (hasChanges bool, count int, err error)
- func HasUnpushedCommits(repoPath, branchName string) (bool, error)
- func IsBranchCheckedOut(mainRepoPath, branchName string) (checkedOut bool, location string, err error)
- func IsWorktree(path string) (bool, error)
- func MatchesBranchPattern(branchName, pattern string) bool
- func NeedsFetch(repoPath string, threshold time.Duration) (bool, time.Duration, error)
- func PruneWorktrees(mainRepoPath string) error
- func PullDefaultBranch(repoPath string) error
- func RemoveWorktree(mainRepoPath, worktreePath string) error
- func ShouldIgnoreBranch(branchName string, patterns []string) bool
- type RepoStatusInfo
- type WorktreeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchExists ¶
BranchExists checks if a branch exists in the repository.
func CheckoutBranch ¶
CheckoutBranch checks out a branch in the specified repository.
func CheckoutExistingBranch ¶
CheckoutExistingBranch creates a worktree for an existing branch at the specified path.
func CloneRepository ¶
CloneRepository clones a git repository into the specified workspace path.
func CloneRepositoryWithOutput ¶
CloneRepositoryWithOutput clones a repository with detailed output and error handling.
func CreateWorktree ¶
CreateWorktree creates a new git worktree with a new branch at the specified path.
func DeleteBranch ¶
DeleteBranch force deletes a branch from the repository.
func FetchRemote ¶
FetchRemote fetches the latest changes from the origin remote.
func GetAheadBehind ¶
GetAheadBehind returns how many commits the branch is ahead/behind its upstream.
func GetAllBranches ¶
GetAllBranches returns a list of all local branch names in the repository.
func GetBranchLastCommit ¶
GetBranchLastCommit returns the relative time and author of the last commit on a branch.
func GetCurrentBranch ¶
GetCurrentBranch returns the name of the currently checked out branch.
func GetDefaultBranch ¶
GetDefaultBranch returns the default branch name for the repository.
func GetLastFetchTime ¶
GetLastFetchTime returns when the repository was last fetched.
func GetMainRepoFromWorktree ¶
GetMainRepoFromWorktree returns the path to the main repository for a given worktree.
func GetModifiedFiles ¶
GetModifiedFiles returns a list of modified file paths.
func GetUnpushedCommitCount ¶
GetUnpushedCommitCount returns the number of commits not pushed to origin.
func HasDifftastic ¶
func HasDifftastic() bool
func HasUncommittedChanges ¶
HasUncommittedChanges checks if the repository has uncommitted changes.
func HasUnpushedCommits ¶
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 ¶
IsWorktree checks if the given path is a git worktree (not a regular clone).
func MatchesBranchPattern ¶
MatchesBranchPattern checks if a branch name matches a glob pattern.
func NeedsFetch ¶
NeedsFetch checks if the repository needs to be fetched.
func PruneWorktrees ¶
PruneWorktrees removes stale worktree entries from the repository.
func PullDefaultBranch ¶
PullDefaultBranch pulls the latest changes from the default branch.
func RemoveWorktree ¶
RemoveWorktree removes a git worktree from the repository.
func ShouldIgnoreBranch ¶
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 ¶
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.