diff

package
v0.0.0-...-66aa08f Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTextFragmentOffsetsBytes

func FindTextFragmentOffsetsBytes(fragments []*gitdiff.TextFragment, r io.ByteReader) ([]int64, error)

FindTextFragmentOffsetsBytes scans a file and searches for occurrences of diff fragments. If all of the fragments can be found in the file, a list of byte offsets is returned at which the fragments are present. These can then be provided to ReplaceTextFragments() to perform the actual substitution.

func ReplaceTextFragments

func ReplaceTextFragments(dst ByteStringWriter, src io.Reader, fragments []*gitdiff.TextFragment, offsetsBytes []int64) error

ReplaceTextFragments performs substitutions on an input file, replacing the contents of fragments in a diff file with the parts that need to be added. The offsets at which substitutions need to be performed are provided in the form of a list that can be obtained by calling FindTextFragmentOffsetsBytes().

Types

type ByteStringWriter

type ByteStringWriter interface {
	io.Writer
	io.StringWriter
}

Jump to

Keyboard shortcuts

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