git

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package git runs git commands against a repository on disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RepoStatus

type RepoStatus struct {
	// StagedFiles lists files with staged changes.
	StagedFiles []string

	// UnstagedFiles lists files with unstaged changes.
	UnstagedFiles []string

	// UntrackedFiles lists untracked files.
	UntrackedFiles []string
}

RepoStatus represents the current state of the repository.

type ShellExecutor

type ShellExecutor struct {
	// WorkDir is the working directory for git commands.
	// If empty, uses current directory.
	WorkDir string
}

ShellExecutor runs git operations by shelling out to the git binary.

func NewShellExecutor

func NewShellExecutor(workDir string) *ShellExecutor

NewShellExecutor creates a new ShellExecutor.

func (*ShellExecutor) ApplyPatch

func (e *ShellExecutor) ApplyPatch(
	ctx context.Context, patch io.Reader,
) error

ApplyPatch applies a patch to the staging area.

func (*ShellExecutor) Commit

func (e *ShellExecutor) Commit(ctx context.Context, message string) error

Commit creates a commit with the given message.

func (*ShellExecutor) Diff

func (e *ShellExecutor) Diff(
	ctx context.Context, paths ...string,
) (string, error)

Diff returns the unified diff for unstaged changes.

func (*ShellExecutor) DiffCached

func (e *ShellExecutor) DiffCached(
	ctx context.Context, paths ...string,
) (string, error)

DiffCached returns the unified diff for staged changes.

func (*ShellExecutor) Reset

func (e *ShellExecutor) Reset(ctx context.Context) error

Reset unstages all staged changes.

func (*ShellExecutor) ResetPaths

func (e *ShellExecutor) ResetPaths(
	ctx context.Context, paths ...string,
) error

ResetPaths unstages changes for the given paths in one git invocation, so a path git rejects leaves the index untouched rather than half-reset.

func (*ShellExecutor) Status

func (e *ShellExecutor) Status(ctx context.Context) (*RepoStatus, error)

Status returns the current repository status.

Jump to

Keyboard shortcuts

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