aboutsummaryrefslogtreecommitdiffstats
path: root/cache
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-25 21:49:32 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-25 21:49:32 +0200
commit7c6f9ef4aac84e0279cf0b343bd7e0d292485be3 (patch)
tree92a015df69da49662822947de62e86b4e6bb6897 /cache
parent074156634b47bfb6141f20a26ec38a386f9ba1b1 (diff)
downloadgit-bug-7c6f9ef4aac84e0279cf0b343bd7e0d292485be3.tar.gz
cache: add shortcut functions
Diffstat (limited to 'cache')
-rw-r--r--cache/cache.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/cache/cache.go b/cache/cache.go
index a46922be..7c5a80ce 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -11,8 +11,13 @@ import (
type Cache interface {
RegisterRepository(ref string, repo repository.Repo)
RegisterDefaultRepository(repo repository.Repo)
+
ResolveRepo(ref string) (CachedRepo, error)
DefaultRepo() (CachedRepo, error)
+
+ // Shortcut to resolve on the default repo for convenience
+ DefaultResolveBug(id string) (CachedBug, error)
+ DefaultResolveBugPrefix(prefix string) (CachedBug, error)
}
type CachedRepo interface {
@@ -66,6 +71,26 @@ func (c *DefaultCache) ResolveRepo(ref string) (CachedRepo, error) {
return r, nil
}
+func (c *DefaultCache) DefaultResolveBug(id string) (CachedBug, error) {
+ repo, err := c.DefaultRepo()
+
+ if err != nil {
+ return nil, err
+ }
+
+ return repo.ResolveBug(id)
+}
+
+func (c *DefaultCache) DefaultResolveBugPrefix(prefix string) (CachedBug, error) {
+ repo, err := c.DefaultRepo()
+
+ if err != nil {
+ return nil, err
+ }
+
+ return repo.ResolveBugPrefix(prefix)
+}
+
// Repo ------------------------
type CachedRepoImpl struct {