Registering lock clearing functions to Cleaner

Rafael Passos created

Change summary

commands/add.go              | 2 ++
commands/bridge.go           | 2 ++
commands/bridge_configure.go | 2 ++
commands/bridge_pull.go      | 2 ++
commands/bridge_rm.go        | 2 ++
commands/comment.go          | 2 ++
commands/comment_add.go      | 2 ++
commands/deselect.go         | 2 ++
commands/label.go            | 2 ++
commands/label_add.go        | 2 ++
commands/label_rm.go         | 2 ++
commands/ls-labels.go        | 2 ++
commands/ls.go               | 2 ++
commands/pull.go             | 2 ++
commands/push.go             | 2 ++
commands/select.go           | 2 ++
commands/show.go             | 2 ++
commands/status.go           | 2 ++
commands/status_close.go     | 2 ++
commands/status_open.go      | 2 ++
commands/termui.go           | 2 ++
commands/title.go            | 2 ++
commands/title_edit.go       | 2 ++
23 files changed, 46 insertions(+)

Detailed changes

commands/add.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/input"
 	"github.com/spf13/cobra"
 )
@@ -22,6 +23,7 @@ func runAddBug(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	if addMessageFile != "" && addMessage == "" {
 		addTitle, addMessage, err = input.BugCreateFileInput(addMessageFile)

commands/bridge.go 🔗

@@ -5,6 +5,7 @@ import (
 
 	"github.com/MichaelMure/git-bug/bridge"
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/spf13/cobra"
 )
 
@@ -14,6 +15,7 @@ func runBridge(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	configured, err := bridge.ConfiguredBridges(backend)
 	if err != nil {

commands/bridge_configure.go 🔗

@@ -9,6 +9,7 @@ import (
 
 	"github.com/MichaelMure/git-bug/bridge"
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/spf13/cobra"
 )
 
@@ -18,6 +19,7 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	target, err := promptTarget()
 	if err != nil {

commands/bridge_pull.go 🔗

@@ -4,6 +4,7 @@ import (
 	"github.com/MichaelMure/git-bug/bridge"
 	"github.com/MichaelMure/git-bug/bridge/core"
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/spf13/cobra"
 )
 
@@ -13,6 +14,7 @@ func runBridgePull(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	var b *core.Bridge
 

commands/bridge_rm.go 🔗

@@ -3,6 +3,7 @@ package commands
 import (
 	"github.com/MichaelMure/git-bug/bridge"
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/spf13/cobra"
 )
 
@@ -12,6 +13,7 @@ func runBridgeRm(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	err = bridge.RemoveBridges(backend, args[0])
 	if err != nil {

commands/comment.go 🔗

@@ -5,6 +5,7 @@ import (
 
 	"github.com/MichaelMure/git-bug/bug"
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/MichaelMure/git-bug/util/colors"
 	"github.com/MichaelMure/git-bug/util/text"
@@ -17,6 +18,7 @@ func runComment(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/comment_add.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/MichaelMure/git-bug/input"
 	"github.com/spf13/cobra"
@@ -20,6 +21,7 @@ func runCommentAdd(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/deselect.go 🔗

@@ -2,6 +2,7 @@ package commands
 
 import (
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -12,6 +13,7 @@ func runDeselect(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	err = _select.Clear(backend)
 	if err != nil {

commands/label.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -14,6 +15,7 @@ func runLabel(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/label_add.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -14,6 +15,7 @@ func runLabelAdd(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/label_rm.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -14,6 +15,7 @@ func runLabelRm(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/ls-labels.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/spf13/cobra"
 )
 
@@ -13,6 +14,7 @@ func runLsLabel(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	labels := backend.ValidLabels()
 

commands/ls.go 🔗

@@ -6,6 +6,7 @@ import (
 
 	"github.com/MichaelMure/git-bug/bug"
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/util/colors"
 	"github.com/spf13/cobra"
 )
@@ -25,6 +26,7 @@ func runLsBug(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	var query *cache.Query
 	if len(args) >= 1 {

commands/pull.go 🔗

@@ -6,6 +6,7 @@ import (
 
 	"github.com/MichaelMure/git-bug/bug"
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/spf13/cobra"
 )
 
@@ -24,6 +25,7 @@ func runPull(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	fmt.Println("Fetching remote ...")
 

commands/push.go 🔗

@@ -5,6 +5,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/spf13/cobra"
 )
 
@@ -23,6 +24,7 @@ func runPush(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	stdout, err := backend.Push(remote)
 	if err != nil {

commands/select.go 🔗

@@ -5,6 +5,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -19,6 +20,7 @@ func runSelect(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	prefix := args[0]
 

commands/show.go 🔗

@@ -6,6 +6,7 @@ import (
 	"strings"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/MichaelMure/git-bug/util/colors"
 	"github.com/spf13/cobra"
@@ -17,6 +18,7 @@ func runShowBug(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/status.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -14,6 +15,7 @@ func runStatus(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/status_close.go 🔗

@@ -2,6 +2,7 @@ package commands
 
 import (
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -12,6 +13,7 @@ func runStatusClose(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/status_open.go 🔗

@@ -2,6 +2,7 @@ package commands
 
 import (
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -12,6 +13,7 @@ func runStatusOpen(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/termui.go 🔗

@@ -2,6 +2,7 @@ package commands
 
 import (
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/termui"
 	"github.com/spf13/cobra"
 )
@@ -12,6 +13,7 @@ func runTermUI(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	return termui.Run(backend)
 }

commands/title.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/spf13/cobra"
 )
@@ -14,6 +15,7 @@ func runTitle(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {

commands/title_edit.go 🔗

@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/cleaner"
 	"github.com/MichaelMure/git-bug/commands/select"
 	"github.com/MichaelMure/git-bug/input"
 	"github.com/spf13/cobra"
@@ -19,6 +20,7 @@ func runTitleEdit(cmd *cobra.Command, args []string) error {
 		return err
 	}
 	defer backend.Close()
+	cleaner.Register(backend.Close)
 
 	b, args, err := _select.ResolveBug(backend, args)
 	if err != nil {