Merge now copies anchor names

This commit is contained in:
Mike Farah 2021-01-13 09:21:16 +11:00
parent 7518dac99c
commit 55712afea6
3 changed files with 5 additions and 4 deletions

View File

@ -61,6 +61,7 @@ func (n *CandidateNode) UpdateFrom(other *CandidateNode) {
n.Node.Content = other.Node.Content
n.Node.Value = other.Node.Value
n.Node.Alias = other.Node.Alias
n.Node.Anchor = other.Node.Anchor
}
func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) {

View File

@ -180,7 +180,7 @@ g: thongs
f: *cat
```
## Merge does not copy anchor names
## Merge copies anchor names
Given a sample.yml file of:
```yaml
a:
@ -197,7 +197,7 @@ yq eval '.c * .a' sample.yml
will output
```yaml
g: thongs
c: frog
c: &cat frog
```
## Merge with merge anchors

View File

@ -132,11 +132,11 @@ b:
},
},
{
description: "Merge does not copy anchor names",
description: "Merge copies anchor names",
document: `{a: {c: &cat frog}, b: {f: *cat}, c: {g: thongs}}`,
expression: `.c * .a`,
expected: []string{
"D0, P[c], (!!map)::{g: thongs, c: frog}\n",
"D0, P[c], (!!map)::{g: thongs, c: &cat frog}\n",
},
},
{