Skip to content

Commit

Permalink
Fix version (gopasspw#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschulz authored Mar 26, 2018
1 parent f16b70b commit 98ce93e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
21 changes: 15 additions & 6 deletions pkg/action/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<root>"
}
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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/store/root/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions pkg/store/root/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/root/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 98ce93e

Please sign in to comment.