mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Keep comments when using the write commandt o update values
This commit is contained in:
@@ -18,6 +18,7 @@ type UpdateCommand struct {
|
||||
Value *yaml.Node
|
||||
Overwrite bool
|
||||
DontUpdateNodeValue bool
|
||||
DontUpdateComments bool
|
||||
}
|
||||
|
||||
func KindString(kind yaml.Kind) string {
|
||||
|
||||
@@ -27,9 +27,11 @@ func UpdateNavigationStrategy(updateCommand UpdateCommand, autoCreate bool) Navi
|
||||
node.Content = changesToApply.Content
|
||||
node.Anchor = changesToApply.Anchor
|
||||
node.Alias = changesToApply.Alias
|
||||
node.HeadComment = changesToApply.HeadComment
|
||||
node.LineComment = changesToApply.LineComment
|
||||
node.FootComment = changesToApply.FootComment
|
||||
if !updateCommand.DontUpdateComments {
|
||||
node.HeadComment = changesToApply.HeadComment
|
||||
node.LineComment = changesToApply.LineComment
|
||||
node.FootComment = changesToApply.FootComment
|
||||
}
|
||||
} else {
|
||||
log.Debug("skipping update as node already has value %v and overwriteFlag is ", node.Value, updateCommand.Overwrite)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user