diff

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCompact

func FormatCompact(stat string) string

FormatCompact returns a compact multi-line summary: `Files changed: N (+X / -Y)\n M path1\n M path2\n`. Returns empty string if no changes.

func GetDiffStat

func GetDiffStat(dir string) (string, error)

GetDiffStat runs `git diff --stat --no-color` in dir and returns trimmed output. Returns empty string if no changes.

func GetFileDiff

func GetFileDiff(dir, file string) (string, error)

GetFileDiff runs `git diff --no-color -- <file>` in dir for a single file.

func GetFullDiff

func GetFullDiff(dir string) (string, error)

GetFullDiff runs `git diff --no-color` in dir.

func ListChangedFiles

func ListChangedFiles(dir string) ([]string, error)

ListChangedFiles returns the list of file paths with uncommitted changes.

func ParseDiffStat

func ParseDiffStat(output string) ([]FileStat, TotalStat)

ParseDiffStat parses git diff --stat output. Each file line looks like ` path/to/file | 42 +++---`. The summary line looks like `3 files changed, 72 insertions(+), 11 deletions(-)`.

Types

type FileStat

type FileStat struct {
	Path       string
	Insertions int
	Deletions  int
}

FileStat represents one file's change summary.

type TotalStat

type TotalStat struct {
	FileCount  int
	Insertions int
	Deletions  int
}

TotalStat is the aggregate across all files.

Jump to

Keyboard shortcuts

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