From c9009b52990d86c6d2589b786b6545488e8ae6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Thu, 29 Dec 2022 10:26:47 +0100 Subject: [PATCH] commands: don't double build the lamport clocks --- cache/subcache.go | 2 ++ commands/execenv/env.go | 7 ++++--- commands/root.go | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cache/subcache.go b/cache/subcache.go index 7757ce8206f7f265ee5e3254b7b17359f227e526..6a9559ef17574f239c300b5495b0771c5f678ce9 100644 --- a/cache/subcache.go +++ b/cache/subcache.go @@ -139,6 +139,8 @@ func (sc *SubCache[EntityT, ExcerptT, CacheT]) Load() error { return fmt.Errorf("count mismatch between bleve and %s excerpts", sc.namespace) } + // TODO: find a way to check lamport clocks + return nil } diff --git a/commands/execenv/env.go b/commands/execenv/env.go index 9b71a45a71a1f194f206d2ba6574ed3ac103a293..b383dde093ee7bf3526ce1422a69f2fce99f61b6 100644 --- a/commands/execenv/env.go +++ b/commands/execenv/env.go @@ -8,7 +8,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" @@ -87,11 +86,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 } diff --git a/commands/root.go b/commands/root.go index d98f944894b485b5fa26de5016b1335b9a1680ae..cb4fd686fc4f90533ca69a0194926ebcdba41ab5 100644 --- a/commands/root.go +++ b/commands/root.go @@ -8,10 +8,9 @@ import ( "github.com/spf13/cobra" "github.com/MichaelMure/git-bug/commands/bridge" - usercmd "github.com/MichaelMure/git-bug/commands/user" - "github.com/MichaelMure/git-bug/commands/bug" "github.com/MichaelMure/git-bug/commands/execenv" + "github.com/MichaelMure/git-bug/commands/user" ) // These variables are initialized externally during the build. See the Makefile.