diff options
Diffstat (limited to 'commands/user_adopt.go')
-rw-r--r-- | commands/user_adopt.go | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/commands/user_adopt.go b/commands/user_adopt.go index 0eb8b467..521f032f 100644 --- a/commands/user_adopt.go +++ b/commands/user_adopt.go @@ -2,19 +2,17 @@ package commands import ( "github.com/spf13/cobra" - - "github.com/MichaelMure/git-bug/cache" - "github.com/MichaelMure/git-bug/util/interrupt" ) func newUserAdoptCommand() *cobra.Command { env := newEnv() cmd := &cobra.Command{ - Use: "adopt <user-id>", - Short: "Adopt an existing identity as your own.", - Args: cobra.ExactArgs(1), - PreRunE: loadRepo(env), + Use: "adopt <user-id>", + Short: "Adopt an existing identity as your own.", + Args: cobra.ExactArgs(1), + PreRunE: loadBackend(env), + PostRunE: closeBackend(env), RunE: func(cmd *cobra.Command, args []string) error { return runUserAdopt(env, args) }, @@ -24,21 +22,14 @@ func newUserAdoptCommand() *cobra.Command { } func runUserAdopt(env *Env, args []string) error { - backend, err := cache.NewRepoCache(env.repo) - if err != nil { - return err - } - defer backend.Close() - interrupt.RegisterCleaner(backend.Close) - prefix := args[0] - i, err := backend.ResolveIdentityPrefix(prefix) + i, err := env.backend.ResolveIdentityPrefix(prefix) if err != nil { return err } - err = backend.SetUserIdentity(i) + err = env.backend.SetUserIdentity(i) if err != nil { return err } |