2018-09-24 18:11:50 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/MichaelMure/git-bug/bridge"
|
|
|
|
"github.com/MichaelMure/git-bug/bridge/core"
|
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2018-10-25 00:36:39 +03:00
|
|
|
"github.com/MichaelMure/git-bug/util/interrupt"
|
2018-09-24 18:11:50 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func runBridgePull(cmd *cobra.Command, args []string) error {
|
|
|
|
backend, err := cache.NewRepoCache(repo)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer backend.Close()
|
2018-10-25 00:36:39 +03:00
|
|
|
interrupt.RegisterCleaner(backend.Close)
|
2018-09-24 18:11:50 +03:00
|
|
|
|
|
|
|
var b *core.Bridge
|
|
|
|
|
|
|
|
if len(args) == 0 {
|
|
|
|
b, err = bridge.DefaultBridge(backend)
|
|
|
|
} else {
|
2018-10-06 12:55:16 +03:00
|
|
|
b, err = bridge.NewBridgeFromFullName(backend, args[0])
|
2018-09-24 18:11:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = b.ImportAll()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var bridgePullCmd = &cobra.Command{
|
2018-10-17 21:38:10 +03:00
|
|
|
Use: "pull [<name>]",
|
2019-02-24 16:46:08 +03:00
|
|
|
Short: "Pull updates.",
|
2018-10-17 21:38:10 +03:00
|
|
|
PreRunE: loadRepo,
|
|
|
|
RunE: runBridgePull,
|
2018-09-24 18:11:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
bridgeCmd.AddCommand(bridgePullCmd)
|
|
|
|
}
|