diff

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatusDifferent = &Status{Key: "different", Title: "The files are different"}
	StatusIdentical = &Status{Key: "identical", Title: "The files are identical"}
	StatusMissing   = &Status{Key: "missing", Title: "File is not present in the source"}
	StatusNew       = &Status{Key: "new", Title: "File is not present in the target"}
	StatusSkipped   = &Status{Key: "skipped", Title: "File was ignored"}
)
View Source
var AllExamples = []*Example{matching, added, removed, startChange, middleChange, endChange, noIntersect}

Functions

func Apply

func Apply(b []byte, d *Diff) ([]byte, error)

func ApplyInverse

func ApplyInverse(b []byte, d *Diff) ([]byte, error)

Types

type Change

type Change struct {
	From  int `json:"from"`
	To    int `json:"to"`
	Lines Lines
}

type Changes

type Changes []*Change

type Diff

type Diff struct {
	Path    string  `json:"path"`
	Status  *Status `json:"status"`
	Patch   string  `json:"patch,omitempty"`
	Changes Changes `json:"changes,omitempty"`
}

func File

func File(src *file.File, tgt *file.File) *Diff

func (*Diff) String

func (d *Diff) String() string

type Diffs

type Diffs []*Diff

func FileLoader

func FileLoader(mods []string, src file.Files, tgt filesystem.FileLoader, includeUnchanged bool, logger util.Logger) (Diffs, error)

func Files

func Files(src file.Files, tgt file.Files, includeUnchanged bool) Diffs

func (Diffs) HasStatus added in v0.3.2

func (d Diffs) HasStatus(s *Status) bool

func (Diffs) Paths added in v0.2.33

func (d Diffs) Paths() []string

type Edits

type Edits []gotextdiff.TextEdit

type Example

type Example struct {
	File     string `json:"title"`
	Src      string `json:"src"`
	Tgt      string `json:"tgt"`
	Expected Edits  `json:"expected"`
}

func NewExample

func NewExample(fn string, src string, tgt string) *Example

func (*Example) Calc

func (e *Example) Calc() *Result

type Line

type Line struct {
	T string `json:"t"`
	V string `json:"v"`
}

func (Line) String

func (l Line) String() string

type Lines

type Lines []*Line

type Result

type Result struct {
	Filename string  `json:"filename"`
	Src      string  `json:"src"`
	Tgt      string  `json:"tgt"`
	Edits    Edits   `json:"edits"`
	Changes  Changes `json:"changes"`
	Patch    string  `json:"patch"`
}

func Calc

func Calc(fn string, src string, tgt string) *Result

type Results

type Results []*Result

type Status

type Status struct {
	Key   string
	Title string
}

func StatusFromString

func StatusFromString(s string) *Status

func (*Status) MarshalJSON

func (t *Status) MarshalJSON() ([]byte, error)

func (*Status) String

func (t *Status) String() string

func (*Status) StringFor added in v0.3.2

func (t *Status) StringFor(act string) string

func (*Status) UnmarshalJSON

func (t *Status) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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