aboutsummaryrefslogtreecommitdiffstats
path: root/commands/bridge_push.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-06-28 19:09:32 +0200
committerMichael Muré <batolettre@gmail.com>2020-06-28 19:09:32 +0200
commit536c290dfbe6e0741c56f33659563c528c9f09b1 (patch)
tree79ea46f76ac6f69c2e6cbf3323be7c620c39a510 /commands/bridge_push.go
parent26bd1dd11010b4d86cebe2510ad7085a6b316334 (diff)
downloadgit-bug-536c290dfbe6e0741c56f33659563c528c9f09b1.tar.gz
commands: open and close the backend in a single place, simplify commands
Diffstat (limited to 'commands/bridge_push.go')
-rw-r--r--commands/bridge_push.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/commands/bridge_push.go b/commands/bridge_push.go
index 73df87fb..7061a5ca 100644
--- a/commands/bridge_push.go
+++ b/commands/bridge_push.go
@@ -10,7 +10,6 @@ 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/util/interrupt"
)
@@ -18,9 +17,10 @@ func newBridgePushCommand() *cobra.Command {
env := newEnv()
cmd := &cobra.Command{
- Use: "push [<name>]",
- Short: "Push updates.",
- PreRunE: loadRepoEnsureUser(env),
+ Use: "push [<name>]",
+ Short: "Push updates.",
+ PreRunE: loadBackendEnsureUser(env),
+ PostRunE: closeBackend(env),
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgePush(env, args)
},
@@ -31,19 +31,13 @@ func newBridgePushCommand() *cobra.Command {
}
func runBridgePush(env *Env, args []string) error {
- backend, err := cache.NewRepoCache(env.repo)
- if err != nil {
- return err
- }
- defer backend.Close()
- interrupt.RegisterCleaner(backend.Close)
-
var b *core.Bridge
+ var err error
if len(args) == 0 {
- b, err = bridge.DefaultBridge(backend)
+ b, err = bridge.DefaultBridge(env.backend)
} else {
- b, err = bridge.LoadBridge(backend, args[0])
+ b, err = bridge.LoadBridge(env.backend, args[0])
}
if err != nil {