From a40dcc8a6a5acf01d823e1ca0f00e0d24c653655 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Mon, 25 Mar 2019 21:09:56 +0100 Subject: 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 --- bug/bug_actions.go | 46 +++------------------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) (limited to 'bug/bug_actions.go') 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 } -- cgit