gitchanges

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 17 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

Overview

Package gitchanges reads working-tree changes from git for the REPL's Changes panel. Everything comes from the git CLI and the files on disk; it never writes to the repository or its index.

Index

Constants

View Source
const (
	MaxDiffBytes = 1 << 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff struct {
	Hunks    []Hunk
	GapAfter int
	Binary   bool
	TooLarge bool
	OldSize  int64
	NewSize  int64
}

type File

type File struct {
	Path        string
	Status      Status
	HeadOID     string
	Added       int
	Removed     int
	CountsKnown bool
	Binary      bool
	Dir         bool
	ChildCount  int
	Children    []string
	Size        int64
	ModTime     time.Time
}

func Merge

func Merge(existing []File, requested []string, scanned []File) []File

func (File) Key

func (f File) Key() FileKey

type FileKey

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

type Hunk

type Hunk struct {
	OldStart, OldCount int
	NewStart, NewCount int
	Function           string
	GapBefore          int
	Lines              []Line
}

type Line

type Line struct {
	Kind LineKind
	Old  int
	New  int
	Text string
}

type LineKind

type LineKind uint8
const (
	LineContext LineKind = iota
	LineAdded
	LineRemoved
)

type Repo

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

func Open

func Open(ctx context.Context, workDir string) (*Repo, error)

func (*Repo) AbsPath

func (r *Repo) AbsPath(repoPath string) string

func (*Repo) DisplayPath

func (r *Repo) DisplayPath(repoPath string) string

func (*Repo) LoadDiff

func (r *Repo) LoadDiff(ctx context.Context, f File, force bool) (*Diff, error)

func (*Repo) RepoPath

func (r *Repo) RepoPath(workDir, path string) (string, bool)

RepoPath rejects paths outside the scoped working directory.

func (*Repo) Scan

func (r *Repo) Scan(ctx context.Context, paths []string) ([]File, error)

type Status

type Status byte
const (
	StatusModified  Status = 'M'
	StatusAdded     Status = 'A'
	StatusDeleted   Status = 'D'
	StatusUntracked Status = '?'
	StatusConflict  Status = 'U'
)

Jump to

Keyboard shortcuts

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