Skip to content

Commit

Permalink
Merge pull request #166 from dlmather/main
Browse files Browse the repository at this point in the history
Fix format specifier missing errors in strings in tables and missing objects during order change
  • Loading branch information
HeavyWombat authored Jun 15, 2021
2 parents 9b0fa57 + 8c9842d commit db8208e
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions pkg/dyff/output_human.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,31 @@ func (report *HumanReport) generateHumanDetailOutputOrderchange(detail Detail) (
output.WriteString(yellow(fmt.Sprintf("%c order changed\n", ORDERCHANGE)))
switch detail.From.Kind {
case yamlv3.SequenceNode:
asStringList := func(sequenceNode *yamlv3.Node) []string {
asStringList := func(sequenceNode *yamlv3.Node) ([]string, error) {
result := make([]string, len(sequenceNode.Content))
for i, entry := range sequenceNode.Content {
result[i] = entry.Value
if entry.Value == "" {
s, err := yamlString(entry)
if err != nil {
return result, err
}
result[i] = s
}
}

return result
return result, nil
}

from, err := asStringList(detail.From)
if err != nil {
return "", err
}
to, err := asStringList(detail.To)
if err != nil {
return "", err
}

from := asStringList(detail.From)
to := asStringList(detail.To)
const singleLineSeparator = ", "

threshold := term.GetTerminalWidth() / 2
Expand All @@ -299,8 +313,8 @@ func (report *HumanReport) generateHumanDetailOutputOrderchange(detail Detail) (

} else {
output.WriteString(CreateTableStyleString(" ", 2,
red(strings.Join(from, "\n")),
green(strings.Join(to, "\n"))))
red("%s", strings.Join(from, "\n")),
green("%s", strings.Join(to, "\n"))))
}
}

Expand Down Expand Up @@ -361,8 +375,8 @@ func (report *HumanReport) highlightByLine(from, to string) string {

} else {
report.writeTextBlocks(&buf, 0,
red(createStringWithPrefix(" - ", from)),
green(createStringWithPrefix(" + ", to)),
red("%s", createStringWithPrefix(" - ", from)),
green("%s", createStringWithPrefix(" + ", to)),
)
}

Expand Down

0 comments on commit db8208e

Please sign in to comment.