mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
* [fix] Pass remote, if given, to local init as well This should cover the case when creating a new team with an existing remote. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * Remote some noisy logging and correctly handle the passed remote location. Please note that the current implmentation will only work if the remote is fully empty (i.e. git init --bare, nothing more). If you need to work with a non-empty remote use gopass clone for the time being. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> --------- Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
51 lines
1015 B
Go
51 lines
1015 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gopasspw/gopass/internal/config/legacy"
|
|
"github.com/gopasspw/gopass/pkg/debug"
|
|
)
|
|
|
|
func migrateConfigs() error {
|
|
cfg := legacy.LoadWithOptions(true, false)
|
|
if cfg == nil {
|
|
debug.V(2).Log("no legacy config found. not migrating.")
|
|
|
|
return nil
|
|
}
|
|
|
|
c := newGitconfig().LoadAll(cfg.Path)
|
|
|
|
for k, v := range cfg.ConfigMap() {
|
|
var fk string
|
|
switch k {
|
|
case "keychain":
|
|
fk = "age.usekeychain"
|
|
case "path":
|
|
fk = "mounts.path"
|
|
case "safecontent":
|
|
fk = "show.safecontent"
|
|
case "autoclip":
|
|
fk = "generate.autoclip"
|
|
case "showautoclip":
|
|
fk = "show.autoclip"
|
|
default:
|
|
fk = "core." + k
|
|
}
|
|
|
|
if err := c.SetGlobal(fk, v); err != nil {
|
|
return fmt.Errorf("failed to write new config: %w", err)
|
|
}
|
|
}
|
|
for alias, path := range cfg.Mounts {
|
|
if err := c.SetGlobal(mpk(alias), path); err != nil {
|
|
return fmt.Errorf("failed to write new config: %w", err)
|
|
}
|
|
}
|
|
|
|
debug.Log("migrated legacy config from %s", cfg.ConfigPath)
|
|
|
|
return nil
|
|
}
|