mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixed merged anchor reference problem #1482
This commit is contained in:
parent
cf8cfbd865
commit
3f1f66a8ee
@ -338,7 +338,7 @@ func deepCloneWithOptions(node *yaml.Node, cloneContent bool) *yaml.Node {
|
|||||||
Tag: node.Tag,
|
Tag: node.Tag,
|
||||||
Value: node.Value,
|
Value: node.Value,
|
||||||
Anchor: node.Anchor,
|
Anchor: node.Anchor,
|
||||||
Alias: deepClone(node.Alias),
|
Alias: node.Alias,
|
||||||
HeadComment: node.HeadComment,
|
HeadComment: node.HeadComment,
|
||||||
LineComment: node.LineComment,
|
LineComment: node.LineComment,
|
||||||
FootComment: node.FootComment,
|
FootComment: node.FootComment,
|
||||||
|
@ -4,6 +4,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var mergeAnchorAssign = `a: &a
|
||||||
|
x: OriginalValue
|
||||||
|
b:
|
||||||
|
<<: *a`
|
||||||
|
|
||||||
var assignOperatorScenarios = []expressionScenario{
|
var assignOperatorScenarios = []expressionScenario{
|
||||||
{
|
{
|
||||||
description: "Create yaml file",
|
description: "Create yaml file",
|
||||||
@ -20,6 +25,14 @@ var assignOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[], (doc)::a: null\n",
|
"D0, P[], (doc)::a: null\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
document: mergeAnchorAssign,
|
||||||
|
expression: `.c = .b | .a.x = "ModifiedValue" | explode(.)`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[], (doc)::a:\n x: ModifiedValue\nb:\n x: ModifiedValue\nc:\n x: ModifiedValue\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
document: "{}",
|
document: "{}",
|
||||||
|
Loading…
Reference in New Issue
Block a user