gitdiff

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGitRepo

func IsGitRepo(dir string) bool

IsGitRepo checks if the given directory is inside a git repository.

Types

type ChangeStatus

type ChangeStatus int

ChangeStatus represents the type of change to a file.

const (
	StatusModified ChangeStatus = iota
	StatusAdded
	StatusDeleted
	StatusRenamed
	StatusUntracked
	StatusBinary
)

type DeletedLine

type DeletedLine struct {
	OldLineNum int
	Content    string
}

DeletedLine represents a line that was deleted from the old version.

type DiffInfo

type DiffInfo struct {
	ChangedLines map[int]bool          // added/modified line numbers (1-based) in new file
	DeletedAfter map[int][]DeletedLine // deleted lines keyed by the new-file line they appear after (0 = before line 1)
}

DiffInfo contains parsed diff information for a single file.

func DiffFile

func DiffFile(dir, path, ref string) (*DiffInfo, error)

DiffFile returns full diff information for a file relative to the given ref.

type FileChange

type FileChange struct {
	Path    string
	Status  ChangeStatus
	OldPath string // for renames
}

FileChange describes a single changed file.

func ChangedFiles

func ChangedFiles(dir string) ([]FileChange, error)

ChangedFiles returns files with changes relative to HEAD (staged + unstaged + untracked).

func ChangedFilesFrom

func ChangedFilesFrom(dir, ref string) ([]FileChange, error)

ChangedFilesFrom returns files changed relative to a ref (branch, commit, HEAD~N).

Jump to

Keyboard shortcuts

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