From a45ece05e6cc02f8f9d8e669cc5ea942b0728eaa Mon Sep 17 00:00:00 2001 From: Sladyn Date: Tue, 5 Mar 2019 00:03:38 +0530 Subject: ls-id.go: Fixing ls-id Adding check for length of args Pulling bugIds from correct backend. --- commands/ls-id.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'commands') diff --git a/commands/ls-id.go b/commands/ls-id.go index b9866828..55548556 100644 --- a/commands/ls-id.go +++ b/commands/ls-id.go @@ -10,9 +10,17 @@ import ( func runLsID(cmd *cobra.Command, args []string) error { - var backend *cache.RepoCache + backend, err := cache.NewRepoCache(repo) + if err != nil { + return err + } + defer backend.Close() - prefix := args[0] + var prefix string + prefix = "" + if len(args) != 0 { + prefix = args[0] + } for _, id := range backend.AllBugsIds() { if prefix == "" || strings.HasPrefix(id, prefix) { -- cgit From cdd8167aa0c4a8942d5d92d3d600e03d7c4a5e31 Mon Sep 17 00:00:00 2001 From: Sladyn Date: Tue, 5 Mar 2019 17:50:58 +0530 Subject: Combined variable declaration and assignment --- commands/ls-id.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'commands') diff --git a/commands/ls-id.go b/commands/ls-id.go index 55548556..3b0e476e 100644 --- a/commands/ls-id.go +++ b/commands/ls-id.go @@ -16,8 +16,7 @@ func runLsID(cmd *cobra.Command, args []string) error { } defer backend.Close() - var prefix string - prefix = "" + var prefix = "" if len(args) != 0 { prefix = args[0] } -- cgit From 2f06e76f92e28ceb0ae15b5736d6774af1b1ce08 Mon Sep 17 00:00:00 2001 From: Sladyn Date: Wed, 6 Mar 2019 17:25:32 +0530 Subject: Added Register.Cleaner --- commands/ls-id.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'commands') diff --git a/commands/ls-id.go b/commands/ls-id.go index 3b0e476e..8dc94ec7 100644 --- a/commands/ls-id.go +++ b/commands/ls-id.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/util/interrupt" "github.com/spf13/cobra" ) @@ -15,6 +16,7 @@ func runLsID(cmd *cobra.Command, args []string) error { return err } defer backend.Close() + interrupt.RegisterCleaner(backend.Close) var prefix = "" if len(args) != 0 { -- cgit