bug: wrap dag.Entity into a full Bug in MergeAll

Michael Muré created

Change summary

bug/bug_actions.go                | 21 ++++++++++++++++++++-
cache/repo_cache_test.go          |  2 +-
entity/dag/entity_actions_test.go |  2 +-
identity/identity_actions_test.go |  2 +-
4 files changed, 23 insertions(+), 4 deletions(-)

Detailed changes

bug/bug_actions.go 🔗

@@ -49,7 +49,26 @@ func MergeAll(repo repository.ClockedRepo, remote string, author identity.Interf
 	// invalidate entities if necessary.
 	identityResolver := identity.NewSimpleResolver(repo)
 
-	return dag.MergeAll(def, repo, identityResolver, remote, author)
+	out := make(chan entity.MergeResult)
+
+	go func() {
+		defer close(out)
+
+		results := dag.MergeAll(def, repo, identityResolver, remote, author)
+
+		// wrap the dag.Entity into a complete Bug
+		for result := range results {
+			result := result
+			if result.Entity != nil {
+				result.Entity = &Bug{
+					Entity: result.Entity.(*dag.Entity),
+				}
+			}
+			out <- result
+		}
+	}()
+
+	return out
 }
 
 // RemoveBug will remove a local bug from its entity.Id

cache/repo_cache_test.go 🔗

@@ -108,7 +108,7 @@ func TestCache(t *testing.T) {
 	require.NoError(t, err)
 }
 
-func TestPushPull(t *testing.T) {
+func TestCachePushPull(t *testing.T) {
 	repoA, repoB, remote := repository.SetupGoGitReposAndRemote()
 	defer repository.CleanupTestRepos(repoA, repoB, remote)
 

entity/dag/entity_actions_test.go 🔗

@@ -23,7 +23,7 @@ func allEntities(t testing.TB, bugs <-chan StreamedEntity) []*Entity {
 	return result
 }
 
-func TestPushPull(t *testing.T) {
+func TestEntityPushPull(t *testing.T) {
 	repoA, repoB, remote, id1, id2, resolver, def := makeTestContextRemote(t)
 	defer repository.CleanupTestRepos(repoA, repoB, remote)
 

identity/identity_actions_test.go 🔗

@@ -8,7 +8,7 @@ import (
 	"github.com/MichaelMure/git-bug/repository"
 )
 
-func TestPushPull(t *testing.T) {
+func TestIdentityPushPull(t *testing.T) {
 	repoA, repoB, remote := repository.SetupGoGitReposAndRemote()
 	defer repository.CleanupTestRepos(repoA, repoB, remote)