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/label.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'commands/label.go') diff --git a/commands/label.go b/commands/label.go index 6c729ff5..b545852f 100644 --- a/commands/label.go +++ b/commands/label.go @@ -4,8 +4,7 @@ import ( "errors" "os" - "github.com/MichaelMure/git-bug/bug" - "github.com/MichaelMure/git-bug/bug/operations" + "github.com/MichaelMure/git-bug/cache" "github.com/spf13/cobra" ) @@ -20,6 +19,12 @@ func runLabel(cmd *cobra.Command, args []string) error { return errors.New("You must provide a label") } + backend, err := cache.NewRepoCache(repo) + if err != nil { + return err + } + defer backend.Close() + prefix := args[0] var add, remove []string @@ -30,23 +35,17 @@ func runLabel(cmd *cobra.Command, args []string) error { add = args[1:] } - b, err := bug.FindLocalBug(repo, prefix) + b, err := backend.ResolveBugPrefix(prefix) if err != nil { return err } - author, err := bug.GetUser(repo) - if err != nil { - return err - } - - err = operations.ChangeLabels(os.Stdout, b, author, add, remove) - + err = b.ChangeLabels(os.Stdout, add, remove) if err != nil { return err } - return b.Commit(repo) + return b.Commit() } var labelCmd = &cobra.Command{ -- cgit