mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
Can now retrieve the alias names of merge anchors #1942
This commit is contained in:
parent
b55f52f377
commit
8cde0c837c
@ -12,6 +12,7 @@ func TestDeepMatch(t *testing.T) {
|
|||||||
ok bool
|
ok bool
|
||||||
}{
|
}{
|
||||||
{"", "", true},
|
{"", "", true},
|
||||||
|
{"<<", "<<", true},
|
||||||
{"", "x", false},
|
{"", "x", false},
|
||||||
{"x", "", false},
|
{"x", "", false},
|
||||||
{"abc", "abc", true},
|
{"abc", "abc", true},
|
||||||
|
@ -269,7 +269,7 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, node *CandidateNode, wante
|
|||||||
value := contents[index+1]
|
value := contents[index+1]
|
||||||
|
|
||||||
//skip the 'merge' tag, find a direct match first
|
//skip the 'merge' tag, find a direct match first
|
||||||
if key.Tag == "!!merge" && !prefs.DontFollowAlias {
|
if key.Tag == "!!merge" && !prefs.DontFollowAlias && wantedKey != "<<" {
|
||||||
log.Debug("Merge anchor")
|
log.Debug("Merge anchor")
|
||||||
err := traverseMergeAnchor(newMatches, value, wantedKey, prefs, splat)
|
err := traverseMergeAnchor(newMatches, value, wantedKey, prefs, splat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -35,6 +35,15 @@ steps:
|
|||||||
`
|
`
|
||||||
|
|
||||||
var traversePathOperatorScenarios = []expressionScenario{
|
var traversePathOperatorScenarios = []expressionScenario{
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
description: "access merge anchors",
|
||||||
|
document: "foo: &foo {x: y}\nbar:\n <<: *foo\n",
|
||||||
|
expression: `.bar["<<"] | alias`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[bar <<], (!!str)::foo\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
description: "dynamically set parent and key",
|
description: "dynamically set parent and key",
|
||||||
|
Loading…
Reference in New Issue
Block a user