diff

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnescapeChars

func UnescapeChars(in []byte) []byte

UnescapeChars reverses escaped characters.

Types

type File

type File struct {
	// The name and path of the file.
	Path string
	// The old name and path of the file.
	OldPath string
	// The type of the file.
	Type FileType
	// The index (SHA1 hash) of the file. For a changed/new file, it is the new SHA,
	// and for a deleted file it becomes "000000".
	SHA string
	// OldSHA is the old index (SHA1 hash) of the file.
	OldSHA string
	// The sections in the file.
	Sections []*Section

	IsBinary    bool
	IsSubmodule bool
	Patch       bytes.Buffer
	// contains filtered or unexported fields
}

File represents a file in diff.

func (*File) IsEmpty

func (f *File) IsEmpty() bool

func (*File) Mode

func (f *File) Mode() enum.EntryMode

Mode returns the mode of the file.

func (*File) NumAdditions

func (f *File) NumAdditions() int

NumAdditions returns the number of additions in the file.

func (*File) NumChanges

func (f *File) NumChanges() int

NumChanges returns the number of additions and deletions in the file.

func (*File) NumDeletions

func (f *File) NumDeletions() int

NumDeletions returns the number of deletions in the file.

func (*File) NumSections

func (f *File) NumSections() int

NumSections returns the number of sections in the file.

func (*File) OldMode

func (f *File) OldMode() enum.EntryMode

OldMode returns the old mode of the file if it's changed.

func (*File) Status

func (f *File) Status() string

type FileType

type FileType uint8

FileType is the file status in diff.

const (
	FileAdd FileType = iota
	FileChange
	FileDelete
	FileRename
)

A list of different file statuses.

type Line

type Line struct {
	Type      LineType // The type of the line
	Content   string   // The content of the line
	LeftLine  int      // The left line number
	RightLine int      // The right line number
}

Line represents a line in diff.

type LineType

type LineType uint8

LineType is the line type in diff.

const (
	DiffLinePlain LineType = iota + 1
	DiffLineAdd
	DiffLineDelete
	DiffLineSection
)

A list of different line types.

type Parser

type Parser struct {
	*bufio.Reader

	IncludePatch bool
	Patch        bytes.Buffer
	// contains filtered or unexported fields
}

func (*Parser) Parse

func (p *Parser) Parse(send func(f *File) error) error

type Section

type Section struct {
	Lines []*Line // lines in the section
	// contains filtered or unexported fields
}

Section represents a section in diff.

func (*Section) Line

func (s *Section) Line(lineType LineType, line int) *Line

Line returns a specific line by given type and line number in a section. nolint: gocognit

func (*Section) NumLines

func (s *Section) NumLines() int

NumLines returns the number of lines in the section.

Jump to

Keyboard shortcuts

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