gitclient

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitEntry

type CommitEntry struct {
	Hash    string
	Message string
}

CommitEntry is a single git log line.

type FileStatus

type FileStatus struct {
	Path     string
	Staged   bool
	Unstaged bool
	Code     string // two-char porcelain code, e.g. "M ", " M", "??"
}

FileStatus represents the git status of a single file.

type GitClient

type GitClient struct {
	Root string
}

GitClient wraps exec git calls for a specific repo root.

func New

func New(root string) *GitClient

func (*GitClient) Commit

func (g *GitClient) Commit(msg string) error

Commit creates a commit with the given message.

func (*GitClient) Diff

func (g *GitClient) Diff(path string) (string, error)

Diff returns the unstaged diff for path.

func (*GitClient) Log

func (g *GitClient) Log(base string) ([]CommitEntry, error)

Log returns commits on current branch since base (e.g. "main").

func (*GitClient) RemoteURL

func (g *GitClient) RemoteURL(name string) (string, error)

RemoteURL returns the fetch URL of the given remote (e.g. "origin").

func (*GitClient) ResetFile

func (g *GitClient) ResetFile(path string) error

ResetFile discards all changes to path (staged + unstaged).

func (*GitClient) Stage

func (g *GitClient) Stage(path string) error

Stage stages a file.

func (*GitClient) StagedDiff

func (g *GitClient) StagedDiff(path string) (string, error)

StagedDiff returns the staged diff for path.

func (*GitClient) Status

func (g *GitClient) Status() ([]FileStatus, error)

Status returns modified/staged/untracked files.

func (*GitClient) Unstage

func (g *GitClient) Unstage(path string) error

Unstage removes a file from staging.

Jump to

Keyboard shortcuts

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