mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixed merge comments
This commit is contained in:
parent
3722367fbb
commit
21a9e506cb
@ -86,7 +86,14 @@ func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) {
|
||||
if n.Node.Style == 0 {
|
||||
n.Node.Style = other.Node.Style
|
||||
}
|
||||
n.Node.FootComment = n.Node.FootComment + other.Node.FootComment
|
||||
n.Node.HeadComment = n.Node.HeadComment + other.Node.HeadComment
|
||||
n.Node.LineComment = n.Node.LineComment + other.Node.LineComment
|
||||
|
||||
if other.Node.FootComment != "" {
|
||||
n.Node.FootComment = other.Node.FootComment
|
||||
}
|
||||
if other.Node.HeadComment != "" {
|
||||
n.Node.HeadComment = other.Node.HeadComment
|
||||
}
|
||||
if other.Node.LineComment != "" {
|
||||
n.Node.LineComment = other.Node.LineComment
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ func multiply(preferences multiplyPreferences) func(d *dataTreeNavigator, contex
|
||||
(lhs.Node.Kind == yaml.SequenceNode && rhs.Node.Kind == yaml.SequenceNode) {
|
||||
|
||||
var newBlank = lhs.CreateChild(nil, &yaml.Node{})
|
||||
|
||||
var newThing, err = mergeObjects(d, context, newBlank, lhs, multiplyPreferences{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -4,6 +4,26 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var doc1 = `list:
|
||||
# Hi this is a comment.
|
||||
# Hello this is another comment.
|
||||
- "abc"`
|
||||
|
||||
var doc2 = `list2:
|
||||
# This is yet another comment.
|
||||
# Indeed this is yet another comment.
|
||||
- "123"`
|
||||
|
||||
var docExpected = `D0, P[], (!!map)::list:
|
||||
# Hi this is a comment.
|
||||
# Hello this is another comment.
|
||||
- "abc"
|
||||
list2:
|
||||
# This is yet another comment.
|
||||
# Indeed this is yet another comment.
|
||||
- "123"
|
||||
`
|
||||
|
||||
var multiplyOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
description: "Multiply integers",
|
||||
@ -12,6 +32,15 @@ var multiplyOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], (!!int)::12\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: doc1,
|
||||
document2: doc2,
|
||||
expression: `select(fi == 0) * select(fi == 1)`,
|
||||
expected: []string{
|
||||
docExpected,
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
expression: `3 * 4.5`,
|
||||
|
Loading…
Reference in New Issue
Block a user