diff

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: Apache-2.0, BSD-3-Clause, CC-BY-4.0, + 2 more Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Patch

func Patch(fh fs.FileHandle, deltas Deltas) error

Patch applys the given deltas to the current file

  • deleted entries are inserted
  • inserted entries are removed

func PatchPath

func PatchPath(path string, deltas Deltas) error

Types

type Delta

type Delta struct {
	Type           DeltaType `json:"kind"`
	LineNrFrom     int       `json:"lineNrFrom"`
	LineNrTarget   int       `json:"lineNrTarget"`
	StartPosFrom   int64     `json:"startPosFrom"`
	StartPosTarget int64     `json:"startPosTarget"`
	Text           string    `json:"text"`
}

Delta represents a patch chunk

func (*Delta) String

func (d *Delta) String() string

type DeltaType

type DeltaType int

DeltaType classifies a patch action like 'delete', 'equal' or 'insert'

const (
	// Del represents a deleted patch chunk
	Del DeltaType = (iota - 1)
	// Eq represents a not changed patch chunk
	Eq
	// Ins represents a added patch chunk
	Ins
)

type Deltas

type Deltas []Delta

Deltas represents all patch chunks of a file

func (Deltas) String

func (deltas Deltas) String() string

type Diff

type Diff struct {
	Deltas                     []Deltas `json:"deltas"`
	Patches                    []string `json:"patches"`
	SideBySideDiffHTMLFragment []string `json:"sideBySideDiffHTMLFragment"`
	InlineDiffHTMLFragment     []string `json:"inlineDiffHTMLFragment"`
	PrettyTextDiff             string
}

func NewDiff

func NewDiff(from, target string, contextSize int) Diff

func NewDiffFromPath

func NewDiffFromPath(from, target string, contextSize int) (Diff, error)

Jump to

Keyboard shortcuts

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