From 7397c94d993541b33e555b758ebdb8f61ff33c6c Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Fri, 31 Aug 2018 13:18:03 +0200 Subject: make CLI commands use the cache to lock the repo properly --- commands/open.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'commands/open.go') diff --git a/commands/open.go b/commands/open.go index 8a5ede3d..db6a5909 100644 --- a/commands/open.go +++ b/commands/open.go @@ -3,8 +3,7 @@ package commands import ( "errors" - "github.com/MichaelMure/git-bug/bug" - "github.com/MichaelMure/git-bug/bug/operations" + "github.com/MichaelMure/git-bug/cache" "github.com/spf13/cobra" ) @@ -17,21 +16,25 @@ func runOpenBug(cmd *cobra.Command, args []string) error { return errors.New("You must provide a bug id") } + backend, err := cache.NewRepoCache(repo) + if err != nil { + return err + } + defer backend.Close() + prefix := args[0] - b, err := bug.FindLocalBug(repo, prefix) + b, err := backend.ResolveBugPrefix(prefix) if err != nil { return err } - author, err := bug.GetUser(repo) + err = b.Open() if err != nil { return err } - operations.Open(b, author) - - return b.Commit(repo) + return b.Commit() } var openCmd = &cobra.Command{ -- cgit v1.2.3