Documentation
¶
Index ¶
Constants ¶
View Source
const (
DefaultContextLines = 3
)
Variables ¶
View Source
var ErrBothFilesEmpty = errors.New("both files are empty")
Functions ¶
This section is empty.
Types ¶
type Chunk ¶
type Chunk interface {
// Content contains the portion of the file.
Content() string
// Type contains the Operation to do with this Chunk.
Type() Operation
}
Chunk represents a portion of a file transformation to another.
type File ¶
type File interface {
// Hash returns the File Hash.
Hash() plumbing.Hash
// Mode returns the FileMode.
Mode() filemode.FileMode
// Path returns the complete Path to the file, including the filename.
Path() string
}
File contains all the file metadata necessary to print some patch formats.
type FilePatch ¶
type FilePatch interface {
// IsBinary returns true if this patch is representing a binary file.
IsBinary() bool
// Files returns the from and to Files, with all the necessary metadata to
// about them. If the patch creates a new file, "from" will be nil.
// If the patch deletes a file, "to" will be nil.
Files() (from, to File)
// Chunks returns a slice of ordered changes to transform "from" File to
// "to" File. If the file is a binary one, Chunks will be empty.
Chunks() []Chunk
}
FilePatch represents the necessary steps to transform one file to another.
type Patch ¶
type Patch interface {
// FilePatches returns a slice of patches per file.
FilePatches() []FilePatch
// Message returns an optional message that can be at the top of the
// Patch representation.
Message() string
}
Patch represents a collection of steps to transform several files.
type UnifiedEncoder ¶
UnifiedEncoder encodes an unified diff into the provided Writer. There are some unsupported features:
- Similarity index for renames
- Sort hash representation
func NewUnifiedEncoder ¶
func NewUnifiedEncoder(w io.Writer, ctxLines int) *UnifiedEncoder
func (*UnifiedEncoder) Encode ¶
func (e *UnifiedEncoder) Encode(patch Patch) error
Click to show internal directories.
Click to hide internal directories.