Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnhandled = errors.New("unhandled git diff syntax")
Functions ¶
func SignificantChange ¶
func SignificantChange(diff string, isSignificant func(*FileDiff, *ContentChange) (bool, string)) (bool, string, error)
SignificantChange Allows a structured diff to be passed into the `isSignificant` function to determine significance. That function can return a message, which is optionally passed as the final argument Returns the first significant change found, or false if non found.
Types ¶
type BinaryDeltaType ¶
type BinaryDeltaType string
const ( BinaryDeltaTypeLiteral BinaryDeltaType = "literal" BinaryDeltaTypeDelta BinaryDeltaType = "delta" )
type BinaryPatch ¶
type BinaryPatch struct { Type BinaryDeltaType `json:"type"` Count int Content string }
type ChangeList ¶
type ChangeList []ContentChange
func (*ChangeList) IsSignificant ¶
func (changes *ChangeList) IsSignificant() bool
type ContentChange ¶
type ContentChange struct { Type ContentChangeType `json:"type"` From string `json:"from"` To string `json:"to"` }
ContentChange is a part of the line that starts with ` `, `-`, `+` Consecutive ContentChange build a line. A `~` is a special case of ContentChange that is used to indicate a new line.
type ContentChangeType ¶
type ContentChangeType string
const ( ContentChangeTypeAdd ContentChangeType = "add" ContentChangeTypeDelete ContentChangeType = "delete" ContentChangeTypeModify ContentChangeType = "modify" ContentChangeTypeNOOP ContentChangeType = "" )
type FileDiff ¶
type FileDiff struct { FromFile string `json:"from_file"` ToFile string `json:"to_file"` Type FileDiffType `json:"type"` IsBinary bool `json:"is_binary"` NewMode string `json:"new_mode"` Hunks []Hunk `json:"hunks"` BinaryPatch []BinaryPatch `json:"binary_patch"` }
FileDiff Source of truth: https://github.com/git/git/blob/master/diffcore.h#L106 Implemented in https://github.com/git/git/blob/master/diff.c#L3496
type FileDiffType ¶
type FileDiffType string
const ( FileDiffTypeAdded FileDiffType = "add" FileDiffTypeDeleted FileDiffType = "delete" FileDiffTypeModified FileDiffType = "modify" )
type Hunk ¶
type Hunk struct { ChangeList ChangeList `json:"change_list"` StartLineNumberOld int `json:"start_line_number_old"` CountOld int `json:"count_old"` StartLineNumberNew int `json:"start_line_number_new"` CountNew int `json:"count_new"` }
Hunk is a line that starts with @@. Each hunk shows one area where the files differ Unified format hunks look like this: @@ from-file-line-numbers to-file-line-numbers @@
line-from-either-file line-from-either-file…
If a hunk contains just one line, only its start line number appears. Otherwise its line numbers look like ‘start,count’. An empty hunk is considered to start at the line that follows the hunk.
type ParserMode ¶
type ParserMode int