aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-07-06 16:32:57 +0200
committerGitHub <noreply@github.com>2019-07-06 16:32:57 +0200
commitf4d4b2f41326d08fdfa574cd4732e950fa9532d8 (patch)
tree04cdd9508bf8c2fd1f3b928dd419a15cdb9709d0 /commands
parentaa4464dbba0b1e0ce39ae53e35971e6924d404d3 (diff)
parent9e611ee66787b9f005540395da2ea10b3320362c (diff)
downloadgit-bug-f4d4b2f41326d08fdfa574cd4732e950fa9532d8.tar.gz
Merge pull request #166 from MichaelMure/github-exporter
[Bridge] GitHub exporter
Diffstat (limited to 'commands')
-rw-r--r--commands/bridge_pull.go4
-rw-r--r--commands/bridge_push.go62
2 files changed, 65 insertions, 1 deletions
diff --git a/commands/bridge_pull.go b/commands/bridge_pull.go
index c7a22d6d..2edabfaf 100644
--- a/commands/bridge_pull.go
+++ b/commands/bridge_pull.go
@@ -3,11 +3,12 @@ package commands
import (
"time"
+ "github.com/spf13/cobra"
+
"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"
- "github.com/spf13/cobra"
)
func runBridgePull(cmd *cobra.Command, args []string) error {
@@ -44,6 +45,7 @@ var bridgePullCmd = &cobra.Command{
Short: "Pull updates.",
PreRunE: loadRepo,
RunE: runBridgePull,
+ Args: cobra.MaximumNArgs(1),
}
func init() {
diff --git a/commands/bridge_push.go b/commands/bridge_push.go
new file mode 100644
index 00000000..11f5ca82
--- /dev/null
+++ b/commands/bridge_push.go
@@ -0,0 +1,62 @@
+package commands
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/spf13/cobra"
+
+ "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"
+)
+
+func runBridgePush(cmd *cobra.Command, args []string) error {
+ backend, err := cache.NewRepoCache(repo)
+ if err != nil {
+ return err
+ }
+ defer backend.Close()
+ interrupt.RegisterCleaner(backend.Close)
+
+ var b *core.Bridge
+
+ if len(args) == 0 {
+ b, err = bridge.DefaultBridge(backend)
+ } else {
+ b, err = bridge.LoadBridge(backend, args[0])
+ }
+
+ if err != nil {
+ return err
+ }
+
+ // TODO: by default export only new events
+ out, err := b.ExportAll(time.Time{})
+ if err != nil {
+ return err
+ }
+
+ for result := range out {
+ if result.Err != nil {
+ fmt.Println(result.Err, result.Reason)
+ } else {
+ fmt.Printf("%s: %s\n", result.String(), result.ID)
+ }
+ }
+
+ return nil
+}
+
+var bridgePushCmd = &cobra.Command{
+ Use: "push [<name>]",
+ Short: "Push updates.",
+ PreRunE: loadRepo,
+ RunE: runBridgePush,
+ Args: cobra.MaximumNArgs(1),
+}
+
+func init() {
+ bridgeCmd.AddCommand(bridgePushCmd)
+}