1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-29 15:09:22 +03:00

Add config migration of paging section to pagers array

This commit is contained in:
Stefan Haller
2025-10-10 15:23:32 +02:00
parent 823b2e9aab
commit 32bf6d685c
2 changed files with 131 additions and 0 deletions

View File

@@ -310,6 +310,11 @@ func computeMigratedConfig(path string, content []byte, changes *ChangesSet) ([]
return nil, false, fmt.Errorf("Couldn't migrate config file at `%s`: %w", path, err)
}
err = migratePagers(&rootNode, changes)
if err != nil {
return nil, false, fmt.Errorf("Couldn't migrate config file at `%s`: %w", path, err)
}
// Add more migrations here...
if reflect.DeepEqual(rootNode, originalCopy) {
@@ -469,6 +474,37 @@ func migrateAllBranchesLogCmd(rootNode *yaml.Node, changes *ChangesSet) error {
})
}
func migratePagers(rootNode *yaml.Node, changes *ChangesSet) error {
return yaml_utils.TransformNode(rootNode, []string{"git"}, func(gitNode *yaml.Node) error {
pagingKeyNode, pagingValueNode := yaml_utils.LookupKey(gitNode, "paging")
if pagingKeyNode == nil || pagingValueNode.Kind != yaml.MappingNode {
// If there's no "paging" section (or it's not an object), there's nothing to do
return nil
}
pagersKeyNode, _ := yaml_utils.LookupKey(gitNode, "pagers")
if pagersKeyNode != nil {
// Conversely, if there *is* already a "pagers" array, we also have nothing to do.
// This covers the case where the user keeps both the "paging" section and the "pagers"
// array for the sake of easier testing of old versions.
return nil
}
pagingKeyNode.Value = "pagers"
pagingContentCopy := pagingValueNode.Content
pagingValueNode.Kind = yaml.SequenceNode
pagingValueNode.Tag = "!!seq"
pagingValueNode.Content = []*yaml.Node{{
Kind: yaml.MappingNode,
Content: pagingContentCopy,
}}
changes.Add("Moved git.paging object to git.pagers array")
return nil
})
}
func (c *AppConfig) GetDebug() bool {
return c.debug
}