conflict

package
v16.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnmergeableFile is returned when the either the file exceeds the
	// fileLimit or no data was read from the file (in case of a binary file).
	ErrUnmergeableFile = errors.New("merging is not supported for file")
	// ErrUnexpectedDelimiter is returned  when the previous section doesn't
	// match the expected flow of sections.
	ErrUnexpectedDelimiter = errors.New("unexpected conflict delimiter")
	// ErrMissingEndDelimiter is returned when the final section parsed doesn't
	// match the expected end state.
	ErrMissingEndDelimiter = errors.New("missing last delimiter")
)

Errors that can occur during parsing of a merge conflict file

Functions

func Resolve added in v16.2.0

func Resolve(src io.Reader, ours, theirs git.ObjectID, path string, resolution Resolution, appendNewLine bool) (io.Reader, error)

Resolve is used to resolve conflicts for a given blob. It expects the blob to be provided as an io.Reader along with the resolutions for the provided blob. Clients can also use appendNewLine to have an additional new line appended to the end of the resolved buffer.

Types

type Entry

type Entry struct {
	Path     string
	Mode     uint
	Contents []byte
}

Entry is a conflict entry with a path and its original preimage contents.

type File

type File struct {
	// contains filtered or unexported fields
}

File contains an ordered list of lines with metadata about potential conflicts.

func Parse

func Parse(src io.Reader, ancestor, our, their *Entry) (File, error)

Parse will read each line and maintain which conflict section it belongs to

func (File) Resolve

func (f File) Resolve(resolution Resolution) ([]byte, error)

Resolve will iterate through each conflict line and replace it with the specified resolution

type Resolution

type Resolution struct {
	// OldPath is the mapping of the path wrt to 'ours' OID
	OldPath string `json:"old_path"`
	// OldPath is the mapping of the path wrt to 'their' OID
	NewPath string `json:"new_path"`

	// Sections is a map which is used to denote which section to select
	// for each conflict. Key is the sectionID, while the value is either
	// "head" or "origin", which denotes the ours/theirs OIDs respectively.
	Sections map[string]string `json:"sections"`

	// Content is used when no sections are defined
	Content string `json:"content"`
}

Resolution indicates how to resolve a conflict

Jump to

Keyboard shortcuts

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