diff options
author | Michael Muré <batolettre@gmail.com> | 2020-10-04 20:45:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-04 20:45:42 +0200 |
commit | 68e2a72b2a3047d84aba44f22751fb13b34553c1 (patch) | |
tree | 6e1496a1a6603abbd473cc0060a5acebc763a68b /cache | |
parent | d56ce3d5d9f5ef74201a8ee7c25be4820d435b47 (diff) | |
parent | ca720f165cb286d4372ad48595e532a2423f2f07 (diff) | |
download | git-bug-68e2a72b2a3047d84aba44f22751fb13b34553c1.tar.gz |
Merge pull request #455 from MichaelMure/bug-loading-fix
cache,bug,identity: structural change
Diffstat (limited to 'cache')
-rw-r--r-- | cache/bug_excerpt.go | 2 | ||||
-rw-r--r-- | cache/identity_cache.go | 2 | ||||
-rw-r--r-- | cache/repo_cache.go | 4 | ||||
-rw-r--r-- | cache/repo_cache_bug.go | 2 | ||||
-rw-r--r-- | cache/resolvers.go | 22 |
5 files changed, 28 insertions, 4 deletions
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go index 14201c6a..631c13cb 100644 --- a/cache/bug_excerpt.go +++ b/cache/bug_excerpt.go @@ -92,7 +92,7 @@ func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt { } switch snap.Author.(type) { - case *identity.Identity: + case *identity.Identity, *IdentityCache: e.AuthorId = snap.Author.Id() case *identity.Bare: e.LegacyAuthor = LegacyAuthorExcerpt{ diff --git a/cache/identity_cache.go b/cache/identity_cache.go index eb5ee183..25e273b9 100644 --- a/cache/identity_cache.go +++ b/cache/identity_cache.go @@ -4,6 +4,8 @@ import ( "github.com/MichaelMure/git-bug/identity" ) +var _ identity.Interface = &IdentityCache{} + // IdentityCache is a wrapper around an Identity for caching. type IdentityCache struct { *identity.Identity diff --git a/cache/repo_cache.go b/cache/repo_cache.go index eeb7fb90..51302932 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -179,7 +179,7 @@ func (c *RepoCache) buildCache() error { c.identitiesExcerpts = make(map[entity.Id]*IdentityExcerpt) - allIdentities := identity.ReadAllLocalIdentities(c.repo) + allIdentities := identity.ReadAllLocal(c.repo) for i := range allIdentities { if i.Err != nil { @@ -195,7 +195,7 @@ func (c *RepoCache) buildCache() error { c.bugExcerpts = make(map[entity.Id]*BugExcerpt) - allBugs := bug.ReadAllLocalBugs(c.repo) + allBugs := bug.ReadAllLocal(c.repo) for b := range allBugs { if b.Err != nil { diff --git a/cache/repo_cache_bug.go b/cache/repo_cache_bug.go index 37b91c54..0c583e0d 100644 --- a/cache/repo_cache_bug.go +++ b/cache/repo_cache_bug.go @@ -136,7 +136,7 @@ func (c *RepoCache) ResolveBug(id entity.Id) (*BugCache, error) { } c.muBug.RUnlock() - b, err := bug.ReadLocalBug(c.repo, id) + b, err := bug.ReadLocalWithResolver(c.repo, newIdentityCacheResolver(c), id) if err != nil { return nil, err } diff --git a/cache/resolvers.go b/cache/resolvers.go new file mode 100644 index 00000000..36b70d3b --- /dev/null +++ b/cache/resolvers.go @@ -0,0 +1,22 @@ +package cache + +import ( + "github.com/MichaelMure/git-bug/entity" + "github.com/MichaelMure/git-bug/identity" +) + +var _ identity.Resolver = &identityCacheResolver{} + +// identityCacheResolver is an identity Resolver that retrieve identities from +// the cache +type identityCacheResolver struct { + cache *RepoCache +} + +func newIdentityCacheResolver(cache *RepoCache) *identityCacheResolver { + return &identityCacheResolver{cache: cache} +} + +func (i *identityCacheResolver) ResolveIdentity(id entity.Id) (identity.Interface, error) { + return i.cache.ResolveIdentity(id) +} |