Documentation
¶
Index ¶
- type Allower
- type FileDiff
- type FileDiffMode
- type FilterFunc
- type Hunk
- type LargeFileInfo
- type Option
- type PatchReader
- type Unidiff
- func (u *Unidiff) Decorate() ([]FileDiff, error)
- func (u *Unidiff) DecorateSeparateBinary() (binaryDiffs, nonBinaryDiffs []FileDiff, err error)
- func (u *Unidiff) DecorateSingle() (FileDiff, error)
- func (u *Unidiff) Patches() ([]string, error)
- func (u *Unidiff) PatchesBytes() ([][]byte, error)
- func (u *Unidiff) WithAllower(allower *Allower) *Unidiff
- func (u *Unidiff) WithExpandedHunks() *Unidiff
- func (u *Unidiff) WithFilterFunc(fn FilterFunc) *Unidiff
- func (u *Unidiff) WithHunksFilter(id ...string) *Unidiff
- func (u *Unidiff) WithIgnoreBinary() *Unidiff
- func (u *Unidiff) WithInverter() *Unidiff
- func (u *Unidiff) WithJoiner() *Unidiff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allower ¶
type Allower struct {
Patterns []string
// contains filtered or unexported fields
}
Allower is a collection of parsed allow patterns.
func NewAllower ¶
NewAllower creates a new allower given a list of user-provided allow patterns.
type FileDiff ¶
type FileDiff struct {
OrigName string `json:"orig_name"`
NewName string `json:"new_name"`
// PreferredName is either OrigName or NewName. Comments and suggestions are reffering to this name.
PreferredName string `json:"preferred_name"`
IsDeleted bool `json:"is_deleted"`
IsNew bool `json:"is_new"`
IsMoved bool `json:"is_moved"`
IsLarge bool `json:"is_large"`
// LargeFileInfo is non nil when IsLarge is true
LargeFileInfo *LargeFileInfo `json:"large_file_info"`
// If this is true, all other fields are empty.
// Used to represent file that is hidden from the logged-in user.
IsHidden bool `json:"is_hidden"`
Hunks []Hunk `json:"hunks"`
}
type FileDiffMode ¶
type FileDiffMode int
var ( FileDiffModeNew FileDiffMode = 1 FileDiffModeChanged FileDiffMode = 2 FileDiffModeDeleted FileDiffMode = 3 FileDiffModeMoved FileDiffMode = 4 )
func DiffFileStat ¶
func DiffFileStat(fd *diff.FileDiff) (mode FileDiffMode, origName, newName string, err error)
TODO: Can we make this private?
type FilterFunc ¶
FilterFunc is a func that if it returns true, the diff that it's filtering will be removed
type Hunk ¶
type LargeFileInfo ¶
type LargeFileInfo struct {
Size uint64 `json:"size"`
}
type Option ¶
type Option func(*Unidiff)
func WithAllower ¶
func WithHunksFilter ¶
func WithInverter ¶
func WithInverter() Option
type PatchReader ¶
func NewBytesPatchReader ¶
func NewBytesPatchReader(s [][]byte) PatchReader
func NewGitPatchReader ¶
func NewGitPatchReader(diff *git.Diff) PatchReader
func NewStringsPatchReader ¶
func NewStringsPatchReader(s []string) PatchReader
type Unidiff ¶
type Unidiff struct {
// contains filtered or unexported fields
}
func NewUnidiff ¶
func NewUnidiff(diffs PatchReader, logger *zap.Logger, options ...Option) *Unidiff
func (*Unidiff) DecorateSeparateBinary ¶
DecorateSeparateBinary consumes the input and returns two separate []FileDiffs
func (*Unidiff) DecorateSingle ¶
DecorateSingle consumes one item from the input, and returns it as a FileDiff
func (*Unidiff) PatchesBytes ¶
PatchesBytes consumes the input, and returns the patches
func (*Unidiff) WithAllower ¶
func (*Unidiff) WithExpandedHunks ¶
func (*Unidiff) WithFilterFunc ¶
func (u *Unidiff) WithFilterFunc(fn FilterFunc) *Unidiff
func (*Unidiff) WithHunksFilter ¶
func (*Unidiff) WithIgnoreBinary ¶
func (*Unidiff) WithInverter ¶
func (*Unidiff) WithJoiner ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.