git

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckoutBranch

func CheckoutBranch(r *git.Repository, branchName string, force bool) error

CheckoutBranch checks out the given branch name and waits for validation

func FindRepo

func FindRepo(startPath string) (string, error)

FindRepo walks up the directory tree to find a .git directory

func OpenRepo

func OpenRepo(path string) (*git.Repository, error)

OpenRepo returns the go-git repository object for the given path

Types

type Branch

type Branch struct {
	Name       string
	IsCurrent  bool
	LastCommit time.Time
	Hash       string
	Remote     string
	RemoteIdx  int // For handling multiple remotes if needed, simplified here
}

func GetBranches

func GetBranches(r *git.Repository) ([]Branch, error)

GetBranches returns a list of local branches sorted by recency

type Commit

type Commit struct {
	Hash        string
	Message     string
	Author      string
	AuthorEmail string
	When        time.Time
}

func GetRecentCommits

func GetRecentCommits(r *git.Repository, branchName string, n int) ([]Commit, error)

GetRecentCommits returns the last n commits from the given branch (or HEAD if empty)

type FileStatus

type FileStatus struct {
	Path   string
	Status string // M, A, D, ?, etc.
	Staged bool
}

type RepoInfo

type RepoInfo struct {
	Path          string
	CurrentBranch string
	IsClean       bool
	Remotes       []string
	Repo          *git.Repository
}

func GetRepoInfo

func GetRepoInfo(path string) (*RepoInfo, error)

GetRepoInfo opens the repository and extracts basic information

func GetRepoInfoFromRepo

func GetRepoInfoFromRepo(path string, r *git.Repository) (*RepoInfo, error)

type Repository

type Repository = git.Repository

type StashEntry

type StashEntry struct {
	ID        int
	Message   string
	Timestamp time.Time
	Hash      string
}

func GetStashList

func GetStashList(r *git.Repository) ([]StashEntry, error)

GetStashList returns the list of stash entries. Note: go-git support for stash is limited, we might need to parse refs/stash.

type WorkingDirStatus

type WorkingDirStatus struct {
	Files      []FileStatus
	BranchName string
	Modified   int
	Staged     int
	Untracked  int
	Conflicted int
}

func GetWorkingDirStatus

func GetWorkingDirStatus(r *git.Repository) (*WorkingDirStatus, error)

GetWorkingDirStatus returns the status of files in the working directory

Jump to

Keyboard shortcuts

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