mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 10:12:06 +03:00
cache: consistently use "ref" to fetch a repository
This commit is contained in:
parent
bc03a89aa7
commit
9f4da4ce4f
2
cache/multi_repo_cache.go
vendored
2
cache/multi_repo_cache.go
vendored
@ -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 {
|
||||||
|
@ -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()
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user