From cd7ed7ff9e3250c10e97fe16c934b5a6151527bb Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 16 Feb 2019 13:48:46 +0100 Subject: identity: add more test for serialisation and push/pull/merge + fixes --- identity/identity_actions.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'identity/identity_actions.go') diff --git a/identity/identity_actions.go b/identity/identity_actions.go index da7a064c..53997eef 100644 --- a/identity/identity_actions.go +++ b/identity/identity_actions.go @@ -12,7 +12,7 @@ import ( // This does not change the local identities state func Fetch(repo repository.Repo, remote string) (string, error) { remoteRefSpec := fmt.Sprintf(identityRemoteRefPattern, remote) - fetchRefSpec := fmt.Sprintf("%s:%s*", identityRefPattern, remoteRefSpec) + fetchRefSpec := fmt.Sprintf("%s*:%s*", identityRefPattern, remoteRefSpec) return repo.FetchRefs(remote, fetchRefSpec) } @@ -23,8 +23,7 @@ func Push(repo repository.Repo, remote string) (string, error) { } // 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. +// This function will return an error if a merge fail func Pull(repo repository.ClockedRepo, remote string) error { _, err := Fetch(repo, remote) if err != nil { @@ -36,9 +35,7 @@ func Pull(repo repository.ClockedRepo, remote string) error { return merge.Err } if merge.Status == MergeStatusInvalid { - // Not awesome: simply output the merge failure here as this function - // is only used in tests for now. - fmt.Println(merge) + return errors.Errorf("merge failure: %s", merge.Reason) } } @@ -64,7 +61,7 @@ func MergeAll(repo repository.ClockedRepo, remote string) <-chan MergeResult { refSplitted := strings.Split(remoteRef, "/") id := refSplitted[len(refSplitted)-1] - remoteIdentity, err := ReadLocal(repo, remoteRef) + remoteIdentity, err := read(repo, remoteRef) if err != nil { out <- newMergeInvalidStatus(id, errors.Wrap(err, "remote identity is not readable").Error()) -- cgit