diff options
Diffstat (limited to 'commands/execenv')
-rw-r--r-- | commands/execenv/env.go | 19 | ||||
-rw-r--r-- | commands/execenv/env_testing.go | 6 |
2 files changed, 22 insertions, 3 deletions
diff --git a/commands/execenv/env.go b/commands/execenv/env.go index a63f835a..4c6ce204 100644 --- a/commands/execenv/env.go +++ b/commands/execenv/env.go @@ -128,11 +128,28 @@ func LoadBackend(env *Env) func(*cobra.Command, []string) error { return err } - env.Backend, err = cache.NewRepoCache(env.Repo) + var events chan cache.BuildEvent + env.Backend, events, err = cache.NewRepoCache(env.Repo) if err != nil { return err } + if events != nil { + env.Err.Println("Building cache... ") + for event := range events { + if event.Err != nil { + env.Err.Printf("Cache building error [%s]: %v\n", event.Typename, event.Err) + continue + } + switch event.Event { + case cache.BuildEventStarted: + env.Err.Printf("[%s] started\n", event.Typename) + case cache.BuildEventFinished: + env.Err.Printf("[%s] done\n", event.Typename) + } + } + } + cleaner := func(env *Env) interrupt.CleanerFunc { return func() error { if env.Backend != nil { diff --git a/commands/execenv/env_testing.go b/commands/execenv/env_testing.go index 7d9fbd60..5761b410 100644 --- a/commands/execenv/env_testing.go +++ b/commands/execenv/env_testing.go @@ -5,9 +5,10 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/require" + "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/repository" - "github.com/stretchr/testify/require" ) type TestOut struct { @@ -33,8 +34,9 @@ func NewTestEnv(t *testing.T) *Env { buf := new(bytes.Buffer) - backend, err := cache.NewRepoCache(repo) + backend, err := cache.NewRepoCacheNoEvents(repo) require.NoError(t, err) + t.Cleanup(func() { backend.Close() }) |