mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 19:23:34 +01:00
chore: modernize CI and update Go toolchain
- Bump Go from 1.19 to 1.26 and update all dependencies - Rewrite CI workflow with matrix strategy (Linux, macOS, Windows) - Update GitHub Actions to current versions (checkout@v4, setup-go@v5) - Update CodeQL actions from v1 to v3 - Fix cross-platform bug in mock/path.go (path.Join -> filepath.Join) - Clean up dependabot config (weekly schedule, remove stale ignore) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
52
vendor/github.com/sergi/go-diff/diffmatchpatch/diff.go
generated
vendored
52
vendor/github.com/sergi/go-diff/diffmatchpatch/diff.go
generated
vendored
@@ -34,8 +34,6 @@ const (
|
||||
DiffInsert Operation = 1
|
||||
// DiffEqual item represents an equal diff.
|
||||
DiffEqual Operation = 0
|
||||
//IndexSeparator is used to seperate the array indexes in an index string
|
||||
IndexSeparator = ","
|
||||
)
|
||||
|
||||
// Diff represents one diff operation
|
||||
@@ -406,14 +404,11 @@ func (dmp *DiffMatchPatch) DiffLinesToRunes(text1, text2 string) ([]rune, []rune
|
||||
func (dmp *DiffMatchPatch) DiffCharsToLines(diffs []Diff, lineArray []string) []Diff {
|
||||
hydrated := make([]Diff, 0, len(diffs))
|
||||
for _, aDiff := range diffs {
|
||||
chars := strings.Split(aDiff.Text, IndexSeparator)
|
||||
text := make([]string, len(chars))
|
||||
runes := []rune(aDiff.Text)
|
||||
text := make([]string, len(runes))
|
||||
|
||||
for i, r := range chars {
|
||||
i1, err := strconv.Atoi(r)
|
||||
if err == nil {
|
||||
text[i] = lineArray[i1]
|
||||
}
|
||||
for i, r := range runes {
|
||||
text[i] = lineArray[runeToInt(r)]
|
||||
}
|
||||
|
||||
aDiff.Text = strings.Join(text, "")
|
||||
@@ -1151,13 +1146,28 @@ func (dmp *DiffMatchPatch) DiffPrettyText(diffs []Diff) string {
|
||||
|
||||
switch diff.Type {
|
||||
case DiffInsert:
|
||||
_, _ = buff.WriteString("\x1b[32m")
|
||||
_, _ = buff.WriteString(text)
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
lines := strings.Split(text, "\n")
|
||||
for i, line := range lines {
|
||||
_, _ = buff.WriteString("\x1b[32m")
|
||||
_, _ = buff.WriteString(line)
|
||||
if i < len(lines)-1 {
|
||||
_, _ = buff.WriteString("\x1b[0m\n")
|
||||
} else {
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
}
|
||||
}
|
||||
|
||||
case DiffDelete:
|
||||
_, _ = buff.WriteString("\x1b[31m")
|
||||
_, _ = buff.WriteString(text)
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
lines := strings.Split(text, "\n")
|
||||
for i, line := range lines {
|
||||
_, _ = buff.WriteString("\x1b[31m")
|
||||
_, _ = buff.WriteString(line)
|
||||
if i < len(lines)-1 {
|
||||
_, _ = buff.WriteString("\x1b[0m\n")
|
||||
} else {
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
}
|
||||
}
|
||||
case DiffEqual:
|
||||
_, _ = buff.WriteString(text)
|
||||
}
|
||||
@@ -1310,7 +1320,6 @@ func (dmp *DiffMatchPatch) DiffFromDelta(text1 string, delta string) (diffs []Di
|
||||
|
||||
// diffLinesToStrings splits two texts into a list of strings. Each string represents one line.
|
||||
func (dmp *DiffMatchPatch) diffLinesToStrings(text1, text2 string) (string, string, []string) {
|
||||
// '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character.
|
||||
lineArray := []string{""} // e.g. lineArray[4] == 'Hello\n'
|
||||
|
||||
lineHash := make(map[string]int)
|
||||
@@ -1321,12 +1330,11 @@ func (dmp *DiffMatchPatch) diffLinesToStrings(text1, text2 string) (string, stri
|
||||
return intArrayToString(strIndexArray1), intArrayToString(strIndexArray2), lineArray
|
||||
}
|
||||
|
||||
// diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []string.
|
||||
func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []uint32 {
|
||||
// Walk the text, pulling out a substring for each line. text.split('\n') would would temporarily double our memory footprint. Modifying text would create many large strings to garbage collect.
|
||||
// diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index.
|
||||
func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []index {
|
||||
lineStart := 0
|
||||
lineEnd := -1
|
||||
strs := []uint32{}
|
||||
strs := []index{}
|
||||
|
||||
for lineEnd < len(text)-1 {
|
||||
lineEnd = indexOf(text, "\n", lineStart)
|
||||
@@ -1340,11 +1348,11 @@ func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]str
|
||||
lineValue, ok := lineHash[line]
|
||||
|
||||
if ok {
|
||||
strs = append(strs, uint32(lineValue))
|
||||
strs = append(strs, index(lineValue))
|
||||
} else {
|
||||
*lineArray = append(*lineArray, line)
|
||||
lineHash[line] = len(*lineArray) - 1
|
||||
strs = append(strs, uint32(len(*lineArray)-1))
|
||||
strs = append(strs, index(len(*lineArray)-1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user