aboutsummaryrefslogtreecommitdiffstats
path: root/commands/pull.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-07 17:10:40 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-07 17:10:40 +0200
commit61a1173ec3f202b9dc71236205de785e2a454791 (patch)
tree80b9661b1da37baacd324f32421d7fa6fc18e3ff /commands/pull.go
parent265ecd81d22c39cc6daccd938a1d41c5ffab23ad (diff)
downloadgit-bug-61a1173ec3f202b9dc71236205de785e2a454791.tar.gz
bug: refactor the Pull code to have the message formating in the upper layers
Diffstat (limited to 'commands/pull.go')
-rw-r--r--commands/pull.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/commands/pull.go b/commands/pull.go
index e9f0ad3e..ea064d99 100644
--- a/commands/pull.go
+++ b/commands/pull.go
@@ -2,8 +2,9 @@ package commands
import (
"errors"
- "os"
+ "fmt"
+ "github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
"github.com/spf13/cobra"
)
@@ -24,7 +25,28 @@ func runPull(cmd *cobra.Command, args []string) error {
}
defer backend.Close()
- return backend.Pull(remote, os.Stdout)
+ fmt.Println("Fetching remote ...")
+
+ stdout, err := backend.Fetch(remote)
+ if err != nil {
+ return err
+ }
+
+ fmt.Println(stdout)
+
+ fmt.Println("Merging data ...")
+
+ for merge := range backend.MergeAll(remote) {
+ if merge.Err != nil {
+ return merge.Err
+ }
+
+ if merge.Status != bug.MsgMergeNothing {
+ fmt.Printf("%s: %s\n", merge.HumanId, merge.Status)
+ }
+ }
+
+ return nil
}
// showCmd defines the "push" subcommand.