git

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyTree = "4b825dc642cb6eb9a060e54bf899d69f82cf7207"

EmptyTree is git's well-known empty-tree object, used as the base when diffing a root commit (which has no parent).

Variables

This section is empty.

Functions

func DiffTargets

func DiffTargets(args []string) (base, target string, err error)

func Paths added in v0.3.0

func Paths(files []ChangedFile) []string

Paths returns just the paths of the changed files.

func StatusChar

func StatusChar(status string) string

Types

type ChangedFile

type ChangedFile struct {
	Path    string `json:"path"`
	Status  string `json:"status"`
	Added   int    `json:"added"`
	Deleted int    `json:"deleted"`
}

func FilterByPaths

func FilterByPaths(files []ChangedFile, paths []string) []ChangedFile

type CommitInfo

type CommitInfo struct {
	Hash    string `json:"hash"`
	Author  string `json:"author"`
	Date    string `json:"date"`
	Message string `json:"message"`
	Body    string `json:"body,omitempty"`
}

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

func OpenRepo

func OpenRepo() (*Repo, error)

func (*Repo) ChangedFiles

func (r *Repo) ChangedFiles(staged bool) ([]ChangedFile, error)

func (*Repo) CurrentBranch added in v0.3.1

func (r *Repo) CurrentBranch() string

CurrentBranch returns the checked-out branch name, the short commit hash when HEAD is detached, or "" if it can't be determined. go-git can't resolve HEAD in linked worktrees (go-git#1842), so those (and any go-git failure) shell out.

func (*Repo) DiffBetweenCommits

func (r *Repo) DiffBetweenCommits(baseRef, targetRef string) ([]ChangedFile, error)

func (*Repo) ListStashes

func (r *Repo) ListStashes() ([]StashEntry, error)

func (*Repo) Log

func (r *Repo) Log(ref string, maxCount int, paths []string) ([]CommitInfo, error)

func (*Repo) LogAll

func (r *Repo) LogAll(maxCount int, paths []string) ([]CommitInfo, error)

func (*Repo) Root

func (r *Repo) Root() string

func (*Repo) Stage

func (r *Repo) Stage(paths ...string) error

func (*Repo) StageHunk

func (r *Repo) StageHunk(patch string) error

func (*Repo) StatusFiles

func (r *Repo) StatusFiles() ([]StatusFile, error)

func (*Repo) Unstage

func (r *Repo) Unstage(paths ...string) error

func (*Repo) UnstageHunk

func (r *Repo) UnstageHunk(patch string) error

type StashEntry

type StashEntry struct {
	Index   int    `json:"index"`
	Branch  string `json:"branch"`
	Message string `json:"message"`
	Date    string `json:"date"`
}

type StatusFile

type StatusFile struct {
	Path           string `json:"path"`
	StagingStatus  string `json:"staging_status"`
	WorktreeStatus string `json:"worktree_status"`
}

Jump to

Keyboard shortcuts

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