aboutsummaryrefslogtreecommitdiffstats
path: root/commands/execenv/env.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/execenv/env.go')
-rw-r--r--commands/execenv/env.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/commands/execenv/env.go b/commands/execenv/env.go
index 9b71a45a..4be7c247 100644
--- a/commands/execenv/env.go
+++ b/commands/execenv/env.go
@@ -1,6 +1,7 @@
package execenv
import (
+ "encoding/json"
"fmt"
"io"
"os"
@@ -8,7 +9,6 @@ import (
"github.com/spf13/cobra"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/entities/bug"
"github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/interrupt"
@@ -39,6 +39,7 @@ type Out interface {
Printf(format string, a ...interface{})
Print(a ...interface{})
Println(a ...interface{})
+ PrintJSON(v interface{}) error
// String returns what have been written in the output before, as a string.
// This only works in test scenario.
@@ -67,6 +68,15 @@ func (o out) Println(a ...interface{}) {
_, _ = fmt.Fprintln(o, a...)
}
+func (o out) PrintJSON(v interface{}) error {
+ raw, err := json.MarshalIndent(v, "", " ")
+ if err != nil {
+ return err
+ }
+ o.Println(string(raw))
+ return nil
+}
+
func (o out) String() string {
panic("only work with a test env")
}
@@ -87,11 +97,13 @@ func LoadRepo(env *Env) func(*cobra.Command, []string) error {
return fmt.Errorf("unable to get the current working directory: %q", err)
}
- env.Repo, err = repository.OpenGoGitRepo(cwd, gitBugNamespace, []repository.ClockLoader{bug.ClockLoader})
+ // Note: we are not loading clocks here because we assume that LoadRepo is only used
+ // when we don't manipulate entities, or as a child call of LoadBackend which will
+ // read all clocks anyway.
+ env.Repo, err = repository.OpenGoGitRepo(cwd, gitBugNamespace, nil)
if err == repository.ErrNotARepo {
return fmt.Errorf("%s must be run from within a git Repo", RootCommandName)
}
-
if err != nil {
return err
}