aboutsummaryrefslogtreecommitdiffstats
path: root/bug
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 /bug
parent265ecd81d22c39cc6daccd938a1d41c5ffab23ad (diff)
downloadgit-bug-61a1173ec3f202b9dc71236205de785e2a454791.tar.gz
bug: refactor the Pull code to have the message formating in the upper layers
Diffstat (limited to 'bug')
-rw-r--r--bug/bug_actions.go26
-rw-r--r--bug/operations/label_change.go1
2 files changed, 6 insertions, 21 deletions
diff --git a/bug/bug_actions.go b/bug/bug_actions.go
index f9e6d0c6..37c3aa05 100644
--- a/bug/bug_actions.go
+++ b/bug/bug_actions.go
@@ -2,8 +2,6 @@ package bug
import (
"fmt"
- "io"
- "io/ioutil"
"strings"
"github.com/MichaelMure/git-bug/repository"
@@ -28,33 +26,19 @@ func Push(repo repository.Repo, remote string) (string, error) {
return repo.PushRefs(remote, bugsRefPattern+"*")
}
-// Pull does a Fetch and merge the updates into the local bug states
-func Pull(repo repository.Repo, out io.Writer, remote string) error {
- // TODO: return a chan of changes for the cache to be updated properly
-
- if out == nil {
- out = ioutil.Discard
- }
-
- fmt.Fprintf(out, "Fetching remote ...\n")
-
- stdout, err := Fetch(repo, remote)
+// Pull will do a Fetch + MergeAll
+// This function won't give details on the underlying process. If you need more
+// use Fetch and MergeAll separately.
+func Pull(repo repository.Repo, remote string) error {
+ _, err := Fetch(repo, remote)
if err != nil {
return err
}
- out.Write([]byte(stdout))
-
- fmt.Fprintf(out, "Merging data ...\n")
-
for merge := range MergeAll(repo, remote) {
if merge.Err != nil {
return merge.Err
}
-
- if merge.Status != MsgMergeNothing {
- fmt.Fprintf(out, "%s: %s\n", merge.HumanId, merge.Status)
- }
}
return nil
diff --git a/bug/operations/label_change.go b/bug/operations/label_change.go
index 5d343e5b..551b8be0 100644
--- a/bug/operations/label_change.go
+++ b/bug/operations/label_change.go
@@ -61,6 +61,7 @@ func NewLabelChangeOperation(author bug.Person, added, removed []bug.Label) Labe
// ChangeLabels is a convenience function to apply the operation
func ChangeLabels(out io.Writer, b bug.Interface, author bug.Person, add, remove []string) error {
+ // TODO: return a channel of result (like MergeAll) instead of formatting the result for the upper layers
var added, removed []bug.Label
if out == nil {