Skip to content

Commit 3f1f66a

Browse files
committed
Fixed merged anchor reference problem #1482
1 parent cf8cfbd commit 3f1f66a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkg/yqlib/lib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func deepCloneWithOptions(node *yaml.Node, cloneContent bool) *yaml.Node {
338338
Tag: node.Tag,
339339
Value: node.Value,
340340
Anchor: node.Anchor,
341-
Alias: deepClone(node.Alias),
341+
Alias: node.Alias,
342342
HeadComment: node.HeadComment,
343343
LineComment: node.LineComment,
344344
FootComment: node.FootComment,

pkg/yqlib/operator_assign_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import (
44
"testing"
55
)
66

7+
var mergeAnchorAssign = `a: &a
8+
x: OriginalValue
9+
b:
10+
<<: *a`
11+
712
var assignOperatorScenarios = []expressionScenario{
813
{
914
description: "Create yaml file",
@@ -20,6 +25,14 @@ var assignOperatorScenarios = []expressionScenario{
2025
"D0, P[], (doc)::a: null\n",
2126
},
2227
},
28+
{
29+
skipDoc: true,
30+
document: mergeAnchorAssign,
31+
expression: `.c = .b | .a.x = "ModifiedValue" | explode(.)`,
32+
expected: []string{
33+
"D0, P[], (doc)::a:\n x: ModifiedValue\nb:\n x: ModifiedValue\nc:\n x: ModifiedValue\n",
34+
},
35+
},
2336
{
2437
skipDoc: true,
2538
document: "{}",

0 commit comments

Comments
 (0)