cache: consistently use "ref" to fetch a repository

This commit is contained in:
Michael Muré 2019-06-23 21:28:01 +02:00
parent bc03a89aa7
commit 9f4da4ce4f
No known key found for this signature in database
GPG Key ID: A4457C029293126F
3 changed files with 6 additions and 6 deletions

View File

@ -54,7 +54,7 @@ func (c *MultiRepoCache) DefaultRepo() (*RepoCache, error) {
panic("unreachable") panic("unreachable")
} }
// ResolveRepo retrieve a repository by name // ResolveRepo retrieve a repository with a reference
func (c *MultiRepoCache) ResolveRepo(ref string) (*RepoCache, error) { func (c *MultiRepoCache) ResolveRepo(ref string) (*RepoCache, error) {
r, ok := c.repos[ref] r, ok := c.repos[ref]
if !ok { if !ok {

View File

@ -15,9 +15,9 @@ type mutationResolver struct {
cache *cache.MultiRepoCache cache *cache.MultiRepoCache
} }
func (r mutationResolver) getRepo(repoRef *string) (*cache.RepoCache, error) { func (r mutationResolver) getRepo(ref *string) (*cache.RepoCache, error) {
if repoRef != nil { if ref != nil {
return r.cache.ResolveRepo(*repoRef) return r.cache.ResolveRepo(*ref)
} }
return r.cache.DefaultRepo() return r.cache.DefaultRepo()

View File

@ -27,8 +27,8 @@ func (r rootQueryResolver) DefaultRepository(ctx context.Context) (*models.Repos
}, nil }, nil
} }
func (r rootQueryResolver) Repository(ctx context.Context, id string) (*models.Repository, error) { func (r rootQueryResolver) Repository(ctx context.Context, ref string) (*models.Repository, error) {
repo, err := r.cache.ResolveRepo(id) repo, err := r.cache.ResolveRepo(ref)
if err != nil { if err != nil {
return nil, err return nil, err