From d1c5015eed4cfc8db19b17bd4a67e2c12b6cd8ff Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 11 Sep 2018 17:11:16 +0200 Subject: cache: resolved id by prefix using the cache instead of reading bugs --- cache/repo_cache.go | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/cache/repo_cache.go b/cache/repo_cache.go index f0c9ac4a..a46e3a75 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -179,33 +179,17 @@ func (c *RepoCache) ResolveBugPrefix(prefix string) (*BugCache, error) { // preallocate but empty matching := make([]string, 0, 5) - for id := range c.bugs { + for id := range c.excerpts { if strings.HasPrefix(id, prefix) { matching = append(matching, id) } } - // TODO: should check matching bug in the repo as well - if len(matching) > 1 { return nil, fmt.Errorf("Multiple matching bug found:\n%s", strings.Join(matching, "\n")) } - if len(matching) == 1 { - b := c.bugs[matching[0]] - return b, nil - } - - b, err := bug.FindLocalBug(c.repo, prefix) - - if err != nil { - return nil, err - } - - cached := NewBugCache(c, b) - c.bugs[b.Id()] = cached - - return cached, nil + return c.ResolveBug(matching[0]) } func (c *RepoCache) QueryBugs(query *Query) []string { -- cgit