git

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff() ([]byte, error)

Diff executes `git diff` and returns the raw command output. Callers are responsible for parsing or rendering the returned bytes.

func GetFileDiff

func GetFileDiff(filepath string, contextLines int, mode DiffMode) ([]byte, error)

GetFileDiff returns the unified diff for a specific file. contextLines specifies how many context lines to show (0 for default, -1 for full file) mode specifies which changes to show (staged, unstaged, or all)

Types

type DiffMode

type DiffMode int

DiffMode represents which changes to show

const (
	DiffAll      DiffMode = iota // Both staged and unstaged (default)
	DiffStaged                   // Only staged changes (--cached)
	DiffUnstaged                 // Only unstaged changes
)

type FileStat

type FileStat struct {
	Path      string
	Status    FileStatus
	Additions int
	Deletions int
}

FileStat contains metadata about a changed file.

func GetModifiedFiles

func GetModifiedFiles(mode DiffMode, includeUntracked bool) ([]FileStat, error)

GetModifiedFiles returns a list of all files with changes and their stats.

type FileStatus

type FileStatus int

FileStatus represents the status of a modified file.

const (
	StatusModified FileStatus = iota
	StatusAdded
	StatusDeleted
	StatusRenamed
	StatusUntracked
	StatusUnknown
)

Jump to

Keyboard shortcuts

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