From 9f4da4ce4fbbf23798b80289af170c9c42ac73eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Sun, 23 Jun 2019 21:28:01 +0200 Subject: [PATCH] cache: consistently use "ref" to fetch a repository --- cache/multi_repo_cache.go | 2 +- graphql/resolvers/mutation.go | 6 +++--- graphql/resolvers/query.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cache/multi_repo_cache.go b/cache/multi_repo_cache.go index fa5a2041..a55bbcce 100644 --- a/cache/multi_repo_cache.go +++ b/cache/multi_repo_cache.go @@ -54,7 +54,7 @@ func (c *MultiRepoCache) DefaultRepo() (*RepoCache, error) { panic("unreachable") } -// ResolveRepo retrieve a repository by name +// ResolveRepo retrieve a repository with a reference func (c *MultiRepoCache) ResolveRepo(ref string) (*RepoCache, error) { r, ok := c.repos[ref] if !ok { diff --git a/graphql/resolvers/mutation.go b/graphql/resolvers/mutation.go index 9ed4e780..b4f8845a 100644 --- a/graphql/resolvers/mutation.go +++ b/graphql/resolvers/mutation.go @@ -15,9 +15,9 @@ type mutationResolver struct { cache *cache.MultiRepoCache } -func (r mutationResolver) getRepo(repoRef *string) (*cache.RepoCache, error) { - if repoRef != nil { - return r.cache.ResolveRepo(*repoRef) +func (r mutationResolver) getRepo(ref *string) (*cache.RepoCache, error) { + if ref != nil { + return r.cache.ResolveRepo(*ref) } return r.cache.DefaultRepo() diff --git a/graphql/resolvers/query.go b/graphql/resolvers/query.go index 80b5a896..aa4e1d85 100644 --- a/graphql/resolvers/query.go +++ b/graphql/resolvers/query.go @@ -27,8 +27,8 @@ func (r rootQueryResolver) DefaultRepository(ctx context.Context) (*models.Repos }, nil } -func (r rootQueryResolver) Repository(ctx context.Context, id string) (*models.Repository, error) { - repo, err := r.cache.ResolveRepo(id) +func (r rootQueryResolver) Repository(ctx context.Context, ref string) (*models.Repository, error) { + repo, err := r.cache.ResolveRepo(ref) if err != nil { return nil, err