aboutsummaryrefslogtreecommitdiffstats
path: root/bug/bug_actions.go
diff options
context:
space:
mode:
authorMichael Muré <michael.mure@consensys.net>2019-03-25 21:09:56 +0100
committerMichael Muré <michael.mure@consensys.net>2019-03-25 22:06:01 +0100
commita40dcc8a6a5acf01d823e1ca0f00e0d24c653655 (patch)
treeb2fa96a5c9b6ecfd29ba140542e9a5ab18377df3 /bug/bug_actions.go
parentd1d2d720255b203c10404dd208d81b9ad2f68002 (diff)
downloadgit-bug-a40dcc8a6a5acf01d823e1ca0f00e0d24c653655.tar.gz
bug: don't make bug actions drive identity actions
Turns out it was a mistake, who is suprised ? It leaks the abstraction and it's generally much cleaner to let the cache layer make both calls
Diffstat (limited to 'bug/bug_actions.go')
-rw-r--r--bug/bug_actions.go46
1 files changed, 3 insertions, 43 deletions
diff --git a/bug/bug_actions.go b/bug/bug_actions.go
index 20360200..f214716d 100644
--- a/bug/bug_actions.go
+++ b/bug/bug_actions.go
@@ -4,68 +4,28 @@ import (
"fmt"
"strings"
- "github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/repository"
"github.com/pkg/errors"
)
-// Note:
-//
-// For the actions (fetch/push/pull/merge/commit), this package act as a master for
-// the identity package and will also drive the needed identity actions. That is,
-// if bug.Push() is called, identity.Push will also be called to make sure that
-// the dependant identities are also present and up to date on the remote.
-//
-// I'm not entirely sure this is the correct way to do it, as it might introduce
-// too much complexity and hard coupling, but it does make this package easier
-// to use.
-
// Fetch retrieve updates from a remote
// This does not change the local bugs state
func Fetch(repo repository.Repo, remote string) (string, error) {
- stdout, err := identity.Fetch(repo, remote)
- if err != nil {
- return stdout, err
- }
-
remoteRefSpec := fmt.Sprintf(bugsRemoteRefPattern, remote)
fetchRefSpec := fmt.Sprintf("%s*:%s*", bugsRefPattern, remoteRefSpec)
- stdout2, err := repo.FetchRefs(remote, fetchRefSpec)
-
- return stdout + "\n" + stdout2, err
+ return repo.FetchRefs(remote, fetchRefSpec)
}
// Push update a remote with the local changes
func Push(repo repository.Repo, remote string) (string, error) {
- stdout, err := identity.Push(repo, remote)
- if err != nil {
- return stdout, err
- }
-
- stdout2, err := repo.PushRefs(remote, bugsRefPattern+"*")
-
- return stdout + "\n" + stdout2, err
+ return repo.PushRefs(remote, bugsRefPattern+"*")
}
// Pull will do a Fetch + MergeAll
// This function will return an error if a merge fail
func Pull(repo repository.ClockedRepo, remote string) error {
- _, err := identity.Fetch(repo, remote)
- if err != nil {
- return err
- }
-
- for merge := range identity.MergeAll(repo, remote) {
- if merge.Err != nil {
- return merge.Err
- }
- if merge.Status == identity.MergeStatusInvalid {
- return errors.Errorf("merge failure: %s", merge.Reason)
- }
- }
-
- _, err = Fetch(repo, remote)
+ _, err := Fetch(repo, remote)
if err != nil {
return err
}