From 45e540c178533ef9aab01b1c3e782bc63061e313 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 14 Feb 2021 12:38:09 +0100 Subject: bug: wrap dag.Entity into a full Bug in MergeAll --- 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(-) diff --git a/bug/bug_actions.go b/bug/bug_actions.go index 6ca5ffd7..420fb08a 100644 --- a/bug/bug_actions.go +++ b/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 diff --git a/cache/repo_cache_test.go b/cache/repo_cache_test.go index a85fde66..35dc4ffd 100644 --- a/cache/repo_cache_test.go +++ b/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) diff --git a/entity/dag/entity_actions_test.go b/entity/dag/entity_actions_test.go index 402f459c..45e69c7d 100644 --- a/entity/dag/entity_actions_test.go +++ b/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) diff --git a/identity/identity_actions_test.go b/identity/identity_actions_test.go index 54cb2a46..2a5954d6 100644 --- a/identity/identity_actions_test.go +++ b/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) -- cgit