changes

package
v0.15.8 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyTreeRevision = ":empty"

EmptyTreeRevision is the API-only base used to show the contents introduced by a repository's root commit.

View Source
const WorktreeRevision = ":worktree"

WorktreeRevision is the API-only revision used to compare a commit with the current index and filesystem state. A colon cannot appear in a Git ref name, so it cannot shadow a real branch or tag.

Variables

View Source
var ErrClosed = errors.New("change tracker closed")
View Source
var ErrDirtyWorktree = errors.New("local changes can only move between branches at the same commit; clean the worktree before switching to a divergent branch")
View Source
var ErrNoDiff = errors.New("diff not found")
View Source
var ErrNotGitRepository = errors.New("workspace is not a Git repository")

Functions

This section is empty.

Types

type CompareResult added in v0.14.2

type CompareResult struct {
	BaseHash      string
	HeadHash      string
	MergeBaseHash string
	Diffs         []FileDiff
}

type DiffLayer

type DiffLayer string
const (
	DiffCombined DiffLayer = ""
	DiffStaged   DiffLayer = "staged"
	DiffUnstaged DiffLayer = "unstaged"
)

type FileDiff

type FileDiff struct {
	Path         string
	OriginalPath string
	Status       FileStatus
	Patch        string
	Original     string
	Modified     string
}

type FileStatus

type FileStatus int
const (
	StatusAdded FileStatus = iota
	StatusModified
	StatusDeleted
)

type GitBranch

type GitBranch struct {
	Name    string
	Remote  string
	Current bool
}

type GitCommit added in v0.14.2

type GitCommit struct {
	Hash       string
	Parents    []string
	Summary    string
	Author     string
	AuthoredAt time.Time
	Refs       []string
}

type GitFileStatus

type GitFileStatus struct {
	Path           string
	OriginalPath   string
	IndexStatus    string
	WorktreeStatus string
	Staged         bool
	Changed        bool
	Conflict       bool
}

type GitStatus

type GitStatus struct {
	Branch    string
	Upstream  string
	Ahead     int
	Behind    int
	HasRemote bool
	Files     []GitFileStatus
}

type Manager

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

func New

func New(workingDir string) *Manager

func (*Manager) Branches

func (m *Manager) Branches(ctx context.Context, refresh bool) ([]GitBranch, string, error)

func (*Manager) CheckoutBranch

func (m *Manager) CheckoutBranch(ctx context.Context, name, remote string) error

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) Commit

func (m *Manager) Commit(ctx context.Context, message string) (string, error)

func (*Manager) Compare added in v0.14.2

func (m *Manager) Compare(ctx context.Context, base, head string, mergeBase bool) (CompareResult, error)

Compare returns committed file changes from base to head. When mergeBase is true, the base tree is replaced with the commits' common ancestor, matching the three-dot comparison used for pull request file views.

func (*Manager) CreateBranch

func (m *Manager) CreateBranch(ctx context.Context, name string) error

func (*Manager) Diff

func (m *Manager) Diff(ctx context.Context, path string, layer DiffLayer) (FileDiff, error)

func (*Manager) Diffs

func (m *Manager) Diffs(ctx context.Context) ([]FileDiff, error)

func (*Manager) DiffsLayer added in v0.15.1

func (m *Manager) DiffsLayer(ctx context.Context, layer DiffLayer) ([]FileDiff, error)

DiffsLayer returns a consistent snapshot of every change in one Git layer. The manager lock stays held while the status, HEAD tree, and file contents are read so callers such as commit-message generation never mix snapshots.

func (*Manager) Fingerprint

func (m *Manager) Fingerprint(ctx context.Context) uint64

func (*Manager) GitStatus

func (m *Manager) GitStatus(ctx context.Context) (GitStatus, error)

func (*Manager) History added in v0.14.2

func (m *Manager) History(ctx context.Context) ([]GitCommit, error)

History returns commits reachable from all local and remote refs. Ref labels are attached to their tip commits so the UI can render a compact history tree.

func (*Manager) HistoryLimit added in v0.15.1

func (m *Manager) HistoryLimit(ctx context.Context, limit int) ([]GitCommit, error)

HistoryLimit returns at most limit commits, or the complete history when limit is zero. Commits are ordered by committer time, newest first.

func (*Manager) Pull

func (m *Manager) Pull(ctx context.Context) (string, error)

func (*Manager) Push

func (m *Manager) Push(ctx context.Context) (string, error)

func (*Manager) Revert

func (m *Manager) Revert(ctx context.Context, path string) error

func (*Manager) Stage

func (m *Manager) Stage(ctx context.Context, paths []string) error

Stage stages explicit workspace paths. An empty path list stages the entire workspace in one operation.

func (*Manager) Unstage

func (m *Manager) Unstage(ctx context.Context, paths []string) error

Jump to

Keyboard shortcuts

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