conflict

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Local    = 1
	Incoming = 2
)

Represents user's conflict resolution decision

Variables

View Source
var ErrInvalidManualInput = errors.New("Newly edited code is invalid")

ErrInvalidManualInput is thrown when the manual code editing session results in deletion of the conflict markers in the text

Functions

This section is empty.

Types

type Conflict

type Conflict struct {
	File *File

	Choice int
	Start  int
	Middle int
	End    int
	Diff3  []int

	LocalLines           []string
	LocalPureLines       []string
	IncomingLines        []string
	ColoredLocalLines    []string
	ColoredIncomingLines []string

	CurrentName string
	ForeignName string

	TopPeek    int
	BottomPeek int
}

Conflict represents a single conflict that may have occurred

func ExtractConflicts

func ExtractConflicts(f File) (conflicts []Conflict, err error)

ExtractConflicts extracts all conflicts from the provided `File` It returns an error if it fails to parse the conflict markers and if syntax highlighting fatally fails TODO: Prevent crashes from syntax highlighting

func GroupConflictMarkers

func GroupConflictMarkers(lines []string) (conflicts []Conflict, err error)

GroupConflictMarkers groups the provided lines of a file into individual `Conflict` structs It returns an error if the line contains invalid number of conflicts. This may be caused if the user manually edits the file.

func (Conflict) Equal

func (c Conflict) Equal(c2 *Conflict) bool

Equal checks if two `Conflict`s are equal

func (*Conflict) Extract added in v1.1.0

func (c *Conflict) Extract(lines []string) error

Extract extracts lines where conflicts exist and corresponding branch names

func (*Conflict) HighlightSyntax added in v1.0.4

func (c *Conflict) HighlightSyntax() error

HighlightSyntax highlights the stored file lines; both local and incoming lines The highlighted versions of the lines are stored in Conflict.Colored____Lines If the file extension is not supported, no highlights are applied

func (*Conflict) PaddingLines

func (c *Conflict) PaddingLines() (topPadding, bottomPadding []string)

PaddingLines returns top and bottom padding lines based on `TopPeek` and `BottomPeek` values

func (*Conflict) Update

func (c *Conflict) Update(incoming []string) (err error)

Update takes the user's input from an editor and updates the current representation of `Conflict`

func (*Conflict) Valid added in v1.1.0

func (c *Conflict) Valid() bool

Valid checks if the parsed conflict has corresponding begin, separator, and middle line numbers

type File

type File struct {
	AbsolutePath string
	Name         string
	Lines        []string
	Conflicts    []Conflict
}

File represents a single file that contains git merge conflicts

func Find

func Find(cwd string) (files []File, err error)

Find runs `git --no-pager diff --check` in order to detect git conflicts It returns an array of `File`s where each `File` contains conflicts within itself If the parsing fails, it returns an error

func (*File) Read

func (f *File) Read() (err error)

readFile reads all lines of a given file

func (File) WriteChanges

func (f File) WriteChanges() (err error)

WriteChanges writes all the resolved conflicts in a given file to the file system.

Jump to

Keyboard shortcuts

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