difffmt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const UnifiedTimeFormat = "2006-01-02 15:04:05.000000000 -0700"

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffTarget

type DiffTarget struct {
	Path         string
	ModifiedTime time.Time
}

func NewDiffTarget

func NewDiffTarget(path string) *DiffTarget

func (*DiffTarget) LoadStat

func (t *DiffTarget) LoadStat() error

func (*DiffTarget) ReadText

func (t *DiffTarget) ReadText() (string, error)

type Hunk

type Hunk struct {
	Diffs       []LineDiff
	OldLineFrom int
	OldLineTo   int
	NewLineFrom int
	NewLineTo   int
}

func GetHunks

func GetHunks(diffs []LineDiff, contextSize int) []Hunk

func NewHunk

func NewHunk() Hunk

func (*Hunk) AppendDiff

func (h *Hunk) AppendDiff(diff LineDiff)

func (*Hunk) FixDiffs

func (h *Hunk) FixDiffs()

func (*Hunk) NewLineCount

func (h *Hunk) NewLineCount() int

func (*Hunk) OldLineCount

func (h *Hunk) OldLineCount() int

type LineDiff

type LineDiff struct {
	Operation Operation
	Text      string
	OldLine   int
	NewLine   int
	IsEndedLF bool
}

func GetLineDiffsFromDMP

func GetLineDiffsFromDMP(diffs []diffmatchpatch.Diff) []LineDiff

dmp := diffmatchpatch.New() runes1, runes2, lineArray := dmp.DiffLinesToRunes(text1, text2) diffs := dmp.DiffMainRunes(runes1, runes2, false) diffs = dmp.DiffCharsToLines(diffs, lineArray) lineDiffs := difffmt.GetLineDiffsFromDMP(diffs)

type Operation

type Operation int8
const (
	OperationDelete Operation = -1
	OperationInsert Operation = 1
	OperationEqual  Operation = 0
)

func GetOperationFromDMP

func GetOperationFromDMP(operation diffmatchpatch.Operation) Operation

type UnifiedFormat

type UnifiedFormat struct {
	IsColorize          bool
	IsHidingNoLFMessage bool
}

func (UnifiedFormat) Fprint

func (u UnifiedFormat) Fprint(w io.Writer, targetA *DiffTarget, targetB *DiffTarget, hunks []Hunk)

func (UnifiedFormat) Print

func (u UnifiedFormat) Print(targetA *DiffTarget, targetB *DiffTarget, hunks []Hunk)

func (UnifiedFormat) Sprint

func (u UnifiedFormat) Sprint(targetA *DiffTarget, targetB *DiffTarget, hunks []Hunk) string

Jump to

Keyboard shortcuts

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