git

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AheadBehind

func AheadBehind(repoPath, branch string) (ahead, behind int)

AheadBehind uses git rev-list to count commits ahead/behind the remote tracking branch.

func DefaultBranch

func DefaultBranch(repoPath string, fallback string) string

DefaultBranch detects the default branch for a repo. Tries origin/HEAD first, then common branch names, then the current branch.

func DiscoverRepos

func DiscoverRepos(rootPath string) ([]string, error)

DiscoverRepos scans one level of subdirectories for git repos.

func FetchRemote

func FetchRemote(repo *gogit.Repository) error

FetchRemote fetches from the origin remote with SSH auth.

func GetBranchName

func GetBranchName(repo *gogit.Repository) (string, error)

GetBranchName returns the current branch name for a repo.

func GetRepoName

func GetRepoName(repoPath string) (string, error)

GetRepoName returns just the repo name for a path.

func GetRepoNameFromRepo

func GetRepoNameFromRepo(repo *gogit.Repository) (string, error)

GetRepoNameFromRepo extracts the repo name from an already-opened repo.

func GetRepoOwnerAndName

func GetRepoOwnerAndName(repo *gogit.Repository) (string, string, error)

GetRepoOwnerAndName extracts the owner and repo name from origin remote URL.

func IsGitRepository

func IsGitRepository(path string) bool

IsGitRepository checks if a directory contains a .git folder.

func PullChanges

func PullChanges(worktree *gogit.Worktree) error

PullChanges pulls changes from the remote using SSH auth.

func PushChanges

func PushChanges(repo *gogit.Repository) error

PushChanges pushes the current branch to the remote using SSH auth.

func SSHAuth

func SSHAuth() (*ssh.PublicKeys, error)

SSHAuth sets up SSH authentication using the private key file specified by the SSH_KEY env var under ~/.ssh/. Result is cached after the first call.

Types

type Changes

type Changes struct {
	Modified  int
	Added     int
	Deleted   int
	Untracked int
}

Changes holds counts of different change types.

func CountChanges

func CountChanges(status gogit.Status) Changes

CountChanges counts changes using go-git's worktree status.

func CountChangesShell

func CountChangesShell(repoPath string) (Changes, error)

CountChangesShell counts changes using shell git to respect .gitignore.

func (Changes) HasChanges

func (c Changes) HasChanges() bool

HasChanges returns true if any changes exist.

func (Changes) Total

func (c Changes) Total() int

Total returns the total number of changes.

Jump to

Keyboard shortcuts

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