Documentation
¶
Index ¶
- func BranchExists(branch string) bool
- func CheckInRepo() error
- func CheckedOutBranches() (map[string]bool, error)
- func GetBranchTrackingRemote(branch string) (string, error)
- func GetBranchUpstream(branch string) (string, string, error)
- func GetCommitHash(ref string) (string, error)
- func GetCurrentBranch() (string, error)
- func GetCurrentBranchUpstream() (string, error)
- func GetLocalBranches() ([]string, error)
- func GetRemoteBranches(remote string) ([]string, error)
- func GetRemotes() ([]string, error)
- func IsBranchAheadOfRemote(local, remote string) (bool, error)
- func IsDirty() (bool, error)
- func RemoteBranchExists(remote, branch string) (bool, error)
- type FileStatus
- type Repo
- func (r Repo) BranchExists(branch string) bool
- func (r Repo) CheckInRepo() error
- func (r Repo) CheckedOutBranches() (map[string]bool, error)
- func (r Repo) GetBranchTrackingRemote(branch string) (string, error)
- func (r Repo) GetBranchUpstream(branch string) (remote string, remoteBranch string, err error)
- func (r Repo) GetCommitHash(ref string) (string, error)
- func (r Repo) GetCurrentBranch() (string, error)
- func (r Repo) GetCurrentBranchUpstream() (string, error)
- func (r Repo) GetFileStatus(file string) (FileStatus, error)
- func (r Repo) GetLocalBranches() ([]string, error)
- func (r Repo) GetRemoteBranches(remote string) ([]string, error)
- func (r Repo) GetRemotes() ([]string, error)
- func (r Repo) IsBranchAheadOfRemote(localBranch, remoteBranch string) (bool, error)
- func (r Repo) IsDirty() (bool, error)
- func (r Repo) RemoteBranchExists(remote, branch string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchExists ¶
func CheckInRepo ¶
func CheckInRepo() error
func CheckedOutBranches ¶ added in v0.10.0
func GetBranchTrackingRemote ¶
func GetCommitHash ¶
func GetCurrentBranch ¶
func GetLocalBranches ¶
func GetRemoteBranches ¶
func GetRemotes ¶
func IsBranchAheadOfRemote ¶
func RemoteBranchExists ¶
Types ¶
type FileStatus ¶
type FileStatus int
FileStatus represents the status of a file in git.
const ( FileUntracked FileStatus = iota FileModified FileStaged FileDeleted FileUnknown )
func GetFileStatus ¶
func GetFileStatus(file string) (FileStatus, error)
type Repo ¶
type Repo struct {
Dir string
}
Repo is a git repository identified by an absolute path. The zero value addresses the current working directory, matching the CLI's natural binding. Tests should construct Repo{Dir: tmpdir} and use the methods so they can run in parallel without sharing process cwd.
func (Repo) BranchExists ¶
BranchExists checks if a local branch exists.
func (Repo) CheckInRepo ¶
CheckInRepo verifies we're inside a git repository.
func (Repo) CheckedOutBranches ¶ added in v0.10.0
CheckedOutBranches returns the set of branch names currently checked out in any worktree (including the main worktree). Callers use the map for O(1) lookups rather than running a separate subprocess per branch.
func (Repo) GetBranchTrackingRemote ¶
GetBranchTrackingRemote returns the remote that a local branch tracks, or "" if none.
func (Repo) GetBranchUpstream ¶
GetBranchUpstream returns the remote and branch name of the upstream for a local branch. Returns ("", "", nil) if the branch has no upstream configured.
func (Repo) GetCommitHash ¶
GetCommitHash returns the commit hash for a ref.
func (Repo) GetCurrentBranch ¶
GetCurrentBranch returns the name of the current branch.
func (Repo) GetCurrentBranchUpstream ¶
GetCurrentBranchUpstream returns the upstream tracking branch for the current branch. Returns ("", nil) if the current branch has no upstream configured.
func (Repo) GetFileStatus ¶
func (r Repo) GetFileStatus(file string) (FileStatus, error)
GetFileStatus returns the status of a file in git.
func (Repo) GetLocalBranches ¶
GetLocalBranches returns a list of local git branches.
func (Repo) GetRemoteBranches ¶
GetRemoteBranches returns branches for a specific remote.
func (Repo) GetRemotes ¶
GetRemotes returns a list of git remotes.
func (Repo) IsBranchAheadOfRemote ¶
IsBranchAheadOfRemote reports whether localBranch has commits not in remoteBranch.