mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-06 23:46:13 +02:00
Make commit prefixes migration only return true if it enters if statement
This commit is contained in:
parent
38ab7ebefb
commit
72b9e8328d
@ -306,6 +306,7 @@ func changeElementToSequence(changedContent []byte, path []string) ([]byte, erro
|
|||||||
|
|
||||||
func changeCommitPrefixesMap(changedContent []byte) ([]byte, error) {
|
func changeCommitPrefixesMap(changedContent []byte) ([]byte, error) {
|
||||||
return yaml_utils.TransformNode(changedContent, []string{"git", "commitPrefixes"}, func(prefixesNode *yaml.Node) (bool, error) {
|
return yaml_utils.TransformNode(changedContent, []string{"git", "commitPrefixes"}, func(prefixesNode *yaml.Node) (bool, error) {
|
||||||
|
changedAnyNodes := false
|
||||||
if prefixesNode.Kind == yaml.MappingNode {
|
if prefixesNode.Kind == yaml.MappingNode {
|
||||||
for _, contentNode := range prefixesNode.Content {
|
for _, contentNode := range prefixesNode.Content {
|
||||||
if contentNode.Kind == yaml.MappingNode {
|
if contentNode.Kind == yaml.MappingNode {
|
||||||
@ -317,12 +318,11 @@ func changeCommitPrefixesMap(changedContent []byte) ([]byte, error) {
|
|||||||
Kind: yaml.MappingNode,
|
Kind: yaml.MappingNode,
|
||||||
Content: nodeContentCopy,
|
Content: nodeContentCopy,
|
||||||
}}
|
}}
|
||||||
|
changedAnyNodes = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true, nil
|
|
||||||
}
|
}
|
||||||
return false, nil
|
return changedAnyNodes, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,28 @@ func TestCommitPrefixMigrations(t *testing.T) {
|
|||||||
name: "Incomplete Configuration",
|
name: "Incomplete Configuration",
|
||||||
input: "git:",
|
input: "git:",
|
||||||
expected: "git:",
|
expected: "git:",
|
||||||
|
}, {
|
||||||
|
// This test intentionally uses non-standard indentation to test that the migration
|
||||||
|
// does not change the input.
|
||||||
|
name: "No changes made when already migrated",
|
||||||
|
input: `
|
||||||
|
git:
|
||||||
|
commitPrefix:
|
||||||
|
- pattern: "Hello World"
|
||||||
|
replace: "Goodbye"
|
||||||
|
commitPrefixes:
|
||||||
|
foo:
|
||||||
|
- pattern: "^\\w+-\\w+.*"
|
||||||
|
replace: '[JIRA $0] '`,
|
||||||
|
expected: `
|
||||||
|
git:
|
||||||
|
commitPrefix:
|
||||||
|
- pattern: "Hello World"
|
||||||
|
replace: "Goodbye"
|
||||||
|
commitPrefixes:
|
||||||
|
foo:
|
||||||
|
- pattern: "^\\w+-\\w+.*"
|
||||||
|
replace: '[JIRA $0] '`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user