mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Merge now copies anchor names
This commit is contained in:
		
							parent
							
								
									07a6fa4df5
								
							
						
					
					
						commit
						5fc26e9453
					
				| @ -61,6 +61,7 @@ func (n *CandidateNode) UpdateFrom(other *CandidateNode) { | |||||||
| 	n.Node.Content = other.Node.Content | 	n.Node.Content = other.Node.Content | ||||||
| 	n.Node.Value = other.Node.Value | 	n.Node.Value = other.Node.Value | ||||||
| 	n.Node.Alias = other.Node.Alias | 	n.Node.Alias = other.Node.Alias | ||||||
|  | 	n.Node.Anchor = other.Node.Anchor | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) { | func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) { | ||||||
|  | |||||||
| @ -180,7 +180,7 @@ g: thongs | |||||||
| f: *cat | f: *cat | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Merge does not copy anchor names | ## Merge copies anchor names | ||||||
| Given a sample.yml file of: | Given a sample.yml file of: | ||||||
| ```yaml | ```yaml | ||||||
| a: | a: | ||||||
| @ -197,7 +197,7 @@ yq eval '.c * .a' sample.yml | |||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
| g: thongs | g: thongs | ||||||
| c: frog | c: &cat frog | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Merge with merge anchors | ## Merge with merge anchors | ||||||
|  | |||||||
| @ -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}}`, | 		document:    `{a: {c: &cat frog}, b: {f: *cat}, c: {g: thongs}}`, | ||||||
| 		expression:  `.c * .a`, | 		expression:  `.c * .a`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D0, P[c], (!!map)::{g: thongs, c: frog}\n", | 			"D0, P[c], (!!map)::{g: thongs, c: &cat frog}\n", | ||||||
| 		}, | 		}, | ||||||
| 	}, | 	}, | ||||||
| 	{ | 	{ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user