mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Cleanup: flip conditions for less indentation
This commit is contained in:
parent
7fc580fe61
commit
e4c1583fb7
1 changed files with 17 additions and 16 deletions
|
@ -225,17 +225,18 @@ func migrateUserConfig(path string, content []byte) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write config back if changed
|
// Nothing to do if config didn't change
|
||||||
if string(changedContent) != string(content) {
|
if string(changedContent) == string(content) {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write config back
|
||||||
fmt.Println("Provided user config is deprecated but auto-fixable. Attempting to write fixed version back to file...")
|
fmt.Println("Provided user config is deprecated but auto-fixable. Attempting to write fixed version back to file...")
|
||||||
if err := os.WriteFile(path, changedContent, 0o644); err != nil {
|
if err := os.WriteFile(path, changedContent, 0o644); err != nil {
|
||||||
return nil, fmt.Errorf("While attempting to write back fixed user config to %s, an error occurred: %s", path, err)
|
return nil, fmt.Errorf("While attempting to write back fixed user config to %s, an error occurred: %s", path, err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Success. New config written to %s\n", path)
|
fmt.Printf("Success. New config written to %s\n", path)
|
||||||
return changedContent, nil
|
return changedContent, nil
|
||||||
}
|
|
||||||
|
|
||||||
return content, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A pure function helper for testing purposes
|
// A pure function helper for testing purposes
|
||||||
|
@ -295,15 +296,15 @@ func computeMigratedConfig(path string, content []byte) ([]byte, error) {
|
||||||
|
|
||||||
// Add more migrations here...
|
// Add more migrations here...
|
||||||
|
|
||||||
if !reflect.DeepEqual(rootNode, originalCopy) {
|
if reflect.DeepEqual(rootNode, originalCopy) {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
newContent, err := yaml_utils.YamlMarshal(&rootNode)
|
newContent, err := yaml_utils.YamlMarshal(&rootNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to remarsal!\n %w", err)
|
return nil, fmt.Errorf("Failed to remarsal!\n %w", err)
|
||||||
}
|
}
|
||||||
return newContent, nil
|
return newContent, nil
|
||||||
} else {
|
|
||||||
return content, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func changeNullKeybindingsToDisabled(rootNode *yaml.Node) error {
|
func changeNullKeybindingsToDisabled(rootNode *yaml.Node) error {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue