diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 614eaf78..9e194cb7 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -145,17 +145,19 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re } else { mbs = git.ErrorIfMissing } - if r, err := git.OpenRepository(ctx, repositorySpec.Name, repositorySpec.Namespace, gitSpec, repositorySpec.Spec.Deployment, filepath.Join(c.cacheDir, "git"), git.GitRepositoryOptions{ + + r, err := git.OpenRepository(ctx, repositorySpec.Name, repositorySpec.Namespace, gitSpec, repositorySpec.Spec.Deployment, filepath.Join(c.cacheDir, "git"), git.GitRepositoryOptions{ CredentialResolver: c.credentialResolver, UserInfoProvider: c.userInfoProvider, MainBranchStrategy: mbs, UseGitCaBundle: c.useGitCaBundle, - }); err != nil { + }) + if err != nil { return nil, err - } else { - cachedRepo = newRepository(key, repositorySpec, r, c.objectNotifier, c.metadataStore, c.repoSyncFrequency) - c.repositories[key] = cachedRepo } + + cachedRepo = newRepository(key, repositorySpec, r, c.objectNotifier, c.metadataStore, c.repoSyncFrequency) + c.repositories[key] = cachedRepo } else { // If there is an error from the background refresh goroutine, return it. if err := cachedRepo.getRefreshError(); err != nil {