diff options
author | Michael Muré <batolettre@gmail.com> | 2018-08-31 13:18:03 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-08-31 17:22:10 +0200 |
commit | 7397c94d993541b33e555b758ebdb8f61ff33c6c (patch) | |
tree | dbdc52bb6efa03791e5ca84bc8695da5103524d2 /commands/new.go | |
parent | 116a94401f0d3fbf79f7e20716b1c7b739e33246 (diff) | |
download | git-bug-7397c94d993541b33e555b758ebdb8f61ff33c6c.tar.gz |
make CLI commands use the cache to lock the repo properly
Diffstat (limited to 'commands/new.go')
-rw-r--r-- | commands/new.go | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/commands/new.go b/commands/new.go index bd0966e5..ce6479f1 100644 --- a/commands/new.go +++ b/commands/new.go @@ -3,8 +3,7 @@ package commands import ( "fmt" - "github.com/MichaelMure/git-bug/bug" - "github.com/MichaelMure/git-bug/bug/operations" + "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/input" "github.com/spf13/cobra" ) @@ -25,8 +24,14 @@ func runNewBug(cmd *cobra.Command, args []string) error { } } + backend, err := cache.NewRepoCache(repo) + if err != nil { + return err + } + defer backend.Close() + if newMessage == "" || newTitle == "" { - newTitle, newMessage, err = input.BugCreateEditorInput(repo, newTitle, newMessage) + newTitle, newMessage, err = input.BugCreateEditorInput(backend.Repository(), newTitle, newMessage) if err == input.ErrEmptyTitle { fmt.Println("Empty title, aborting.") @@ -37,23 +42,12 @@ func runNewBug(cmd *cobra.Command, args []string) error { } } - author, err := bug.GetUser(repo) - if err != nil { - return err - } - - newBug, err := operations.Create(author, newTitle, newMessage) - if err != nil { - return err - } - - err = newBug.Commit(repo) - + b, err := backend.NewBug(newTitle, newMessage) if err != nil { return err } - fmt.Printf("%s created\n", newBug.HumanId()) + fmt.Printf("%s created\n", b.HumanId()) return nil } |