diff

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 11 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

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

func (Diffs) Paths

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 (s *Status) MarshalJSON() ([]byte, error)

func (*Status) Matches added in v1.2.16

func (s *Status) Matches(x *Status) bool

func (*Status) String

func (s *Status) String() string

func (*Status) StringFor

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

func (*Status) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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