godiff

package module
v0.0.0-...-8656487 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 9 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SegmentTypeContext = "CONTEXT"
	SegmentTypeRemoved = "REMOVED"
	SegmentTypeAdded   = "ADDED"
)

Variables

This section is empty.

Functions

func Note

func Note(String string) string

func WriteChangeset

func WriteChangeset(changeset Changeset, to io.Writer) error

Types

type Changeset

type Changeset struct {
	FromHash   string
	ToHash     string
	Path       string
	Whitespace string
	Diffs      []*Diff
}

func ReadChangeset

func ReadChangeset(r io.Reader) (Changeset, error)

func (Changeset) ForEachComment

func (r Changeset) ForEachComment(callback func(*Diff, *Comment, *Comment))

func (Changeset) ForEachLine

func (r Changeset) ForEachLine(
	callback func(*Diff, *Hunk, *Segment, *Line) error,
) error

type Comment

type Comment struct {
	Id          int64
	Version     int
	Text        string
	CreatedDate UnixTimestamp
	UpdatedDate UnixTimestamp
	Comments    CommentsTree
	Author      struct {
		Name         string
		EmailAddress string
		Id           int
		DisplayName  string
		Active       bool
		Slug         string
		Type         string
	}

	Anchor CommentAnchor

	PermittedOperations struct {
		Editable  bool
		Deletable bool
	}

	Indent   int
	Parented bool
}

func (Comment) Short

func (c Comment) Short(length int) string

type CommentAnchor

type CommentAnchor struct {
	FromHash string
	ToHash   string
	Line     int64  `json:"line"`
	LineType string `json:"lineType"`
	Path     string `json:"path"`
	SrcPath  string `json:"srcPath"`
	FileType string `json:"fileType"`
}

type CommentsTree

type CommentsTree []*Comment

type Diff

type Diff struct {
	Truncated bool
	Source    struct {
		Parent   string
		Name     string
		ToString string
	}
	Destination struct {
		Parent   string
		Name     string
		ToString string
	}
	Hunks []*Hunk

	FileComments CommentsTree
	LineComments CommentsTree

	Note string

	// Lists made only for Stash API compatibility.
	// TODO: move it to `ash`.
	Attributes struct {
		FromHash []string
		ToHash   []string
	}
}

func (Diff) ForEachLine

func (d Diff) ForEachLine(
	callback func(*Diff, *Hunk, *Segment, *Line) error,
) error

func (Diff) GetHashFrom

func (d Diff) GetHashFrom() string

func (Diff) GetHashTo

func (d Diff) GetHashTo() string

type Error

type Error struct {
	LineNumber int
	Message    string
}

func (Error) Error

func (err Error) Error() string

type Hunk

type Hunk struct {
	SourceLine      int64
	SourceSpan      int64
	DestinationLine int64
	DestinationSpan int64
	Truncated       bool
	Segments        []*Segment
}

type Line

type Line struct {
	Destination    int64
	Source         int64
	Line           string
	Truncated      bool
	ConflictMarker string
	CommentIds     []int64
	Comments       CommentsTree
}

type Segment

type Segment struct {
	Type      string
	Truncated bool
	Lines     []*Line
}

func (Segment) GetLineNum

func (s Segment) GetLineNum(l *Line) int64

func (Segment) TextPrefix

func (s Segment) TextPrefix() string

type UnixTimestamp

type UnixTimestamp int

func (UnixTimestamp) String

func (u UnixTimestamp) String() string

Jump to

Keyboard shortcuts

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