From 271d8314a459bde66961a66f71230257ad8bdd47 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Mon, 26 Mar 2018 16:54:17 +0200 Subject: [PATCH] Fix version --- pkg/action/version.go | 21 +++++++++++++++------ pkg/store/root/git.go | 6 +++--- pkg/store/root/store.go | 6 +++--- pkg/store/root/store_test.go | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pkg/action/version.go b/pkg/action/version.go index d62baa1b9a..a386db8cd2 100644 --- a/pkg/action/version.go +++ b/pkg/action/version.go @@ -48,16 +48,25 @@ func (s *Action) Version(ctx context.Context, c *cli.Context) error { u <- "" }(version) + _ = s.Initialized(ctx, c) + cli.VersionPrinter(c) // report all used crypto, sync and fs backends for _, mp := range append(s.Store.MountPoints(), "") { - crypto := s.Store.Crypto(ctx, mp) - fmt.Fprintf(stdout, "[%s] Crypto: %s %s\n", mp, crypto.Name(), crypto.Version(ctx)) - sync := s.Store.Sync(ctx, mp) - fmt.Fprintf(stdout, "[%s] Sync: %s %s\n", mp, sync.Name(), sync.Version(ctx)) - storer := s.Store.Store(ctx, mp) - fmt.Fprintf(stdout, "[%s] Store: %s %s\n", mp, storer.Name(), storer.Version()) + name := mp + if name == "" { + name = "" + } + if crypto := s.Store.Crypto(ctx, mp); crypto != nil { + fmt.Fprintf(stdout, "[%s] Crypto: %s %s\n", name, crypto.Name(), crypto.Version(ctx)) + } + if sync := s.Store.RCS(ctx, mp); sync != nil { + fmt.Fprintf(stdout, "[%s] RCS: %s %s\n", name, sync.Name(), sync.Version(ctx)) + } + if storer := s.Store.Storage(ctx, mp); storer != nil { + fmt.Fprintf(stdout, "[%s] Storage: %s %s\n", name, storer.Name(), storer.Version()) + } } select { diff --git a/pkg/store/root/git.go b/pkg/store/root/git.go index 0df92232a5..7fe761de44 100644 --- a/pkg/store/root/git.go +++ b/pkg/store/root/git.go @@ -8,10 +8,10 @@ import ( "github.com/justwatchcom/gopass/pkg/store" ) -// Sync returns the sync backend -func (r *Store) Sync(ctx context.Context, name string) backend.RCS { +// RCS returns the sync backend +func (r *Store) RCS(ctx context.Context, name string) backend.RCS { _, sub, _ := r.getStore(ctx, name) - if sub == nil { + if sub == nil || !sub.Valid() { return nil } return sub.RCS() diff --git a/pkg/store/root/store.go b/pkg/store/root/store.go index 1f54d5984f..70a8054725 100644 --- a/pkg/store/root/store.go +++ b/pkg/store/root/store.go @@ -87,10 +87,10 @@ func (r *Store) Alias() string { return "" } -// Store returns the storage backend for the given mount point -func (r *Store) Store(ctx context.Context, name string) backend.Storage { +// Storage returns the storage backend for the given mount point +func (r *Store) Storage(ctx context.Context, name string) backend.Storage { _, sub, _ := r.getStore(ctx, name) - if sub == nil { + if sub == nil || !sub.Valid() { return nil } return sub.Storage() diff --git a/pkg/store/root/store_test.go b/pkg/store/root/store_test.go index 1997db9f87..921bad1aff 100644 --- a/pkg/store/root/store_test.go +++ b/pkg/store/root/store_test.go @@ -114,7 +114,7 @@ func TestListNested(t *testing.T) { assert.Equal(t, false, rs.Exists(ctx, "sub1")) assert.Equal(t, true, rs.IsDir(ctx, "sub1")) assert.Equal(t, "", rs.Alias()) - assert.NotNil(t, rs.Store(ctx, "sub1")) + assert.NotNil(t, rs.Storage(ctx, "sub1")) } func createRootStore(ctx context.Context, u *gptest.Unit) (*Store, error) {