aboutsummaryrefslogtreecommitdiffstats
path: root/cache
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-02-26 22:25:52 +0100
committerMichael Muré <batolettre@gmail.com>2019-03-01 22:52:54 +0100
commitbad05a4f3d24eb092724f667ee33bb1956457dd3 (patch)
treeebffb166f1a9f63d56459b0ffee7c3a09ae1042f /cache
parentc235d89d36500e58e3bcadda94e9cab06023dd55 (diff)
downloadgit-bug-bad05a4f3d24eb092724f667ee33bb1956457dd3.tar.gz
cache: better API to access excerpts
Diffstat (limited to 'cache')
-rw-r--r--cache/repo_cache.go32
1 files changed, 20 insertions, 12 deletions
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 7423ee73..2b0fa360 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -387,6 +387,16 @@ func (c *RepoCache) ResolveBug(id string) (*BugCache, error) {
return cached, nil
}
+// ResolveBugExcerpt retrieve a BugExcerpt matching the exact given id
+func (c *RepoCache) ResolveBugExcerpt(id string) (*BugExcerpt, error) {
+ e, ok := c.bugExcerpts[id]
+ if !ok {
+ return nil, bug.ErrBugNotExist
+ }
+
+ return e, nil
+}
+
// ResolveBugPrefix retrieve a bug matching an id prefix. It fails if multiple
// bugs match.
func (c *RepoCache) ResolveBugPrefix(prefix string) (*BugCache, error) {
@@ -489,12 +499,6 @@ func (c *RepoCache) AllBugsIds() []string {
return result
}
-// AllBugExcerpt return all known bug excerpt.
-// This maps is read-only.
-func (c *RepoCache) AllBugExcerpt() map[string]*BugExcerpt {
- return c.bugExcerpts
-}
-
// ValidLabels list valid labels
//
// Note: in the future, a proper label policy could be implemented where valid
@@ -708,6 +712,16 @@ func (c *RepoCache) ResolveIdentity(id string) (*IdentityCache, error) {
return cached, nil
}
+// ResolveIdentityExcerpt retrieve a IdentityExcerpt matching the exact given id
+func (c *RepoCache) ResolveIdentityExcerpt(id string) (*IdentityExcerpt, error) {
+ e, ok := c.identitiesExcerpts[id]
+ if !ok {
+ return nil, identity.ErrIdentityNotExist
+ }
+
+ return e, nil
+}
+
// ResolveIdentityPrefix retrieve an Identity matching an id prefix.
// It fails if multiple identities match.
func (c *RepoCache) ResolveIdentityPrefix(prefix string) (*IdentityCache, error) {
@@ -767,12 +781,6 @@ func (c *RepoCache) AllIdentityIds() []string {
return result
}
-// AllIdentityExcerpt return all known identities excerpt.
-// This maps is read-only.
-func (c *RepoCache) AllIdentityExcerpt() map[string]*IdentityExcerpt {
- return c.identitiesExcerpts
-}
-
func (c *RepoCache) SetUserIdentity(i *IdentityCache) error {
err := identity.SetUserIdentity(c.repo, i.Identity)
if err != nil {