Skip to content

Commit

Permalink
Merge branch 'main' into jkutner/fix-any-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
jromero authored Jul 21, 2021
2 parents c5e0e33 + 5bde87f commit 359df6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/registry/registry_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ const defaultRegistryDir = "registry"

// Cache is a RegistryCache
type Cache struct {
logger logging.Logger
url *url.URL
Root string
logger logging.Logger
url *url.URL
Root string
RegistryDir string
}

const GithubIssueTitleTemplate = "{{ if .Yanked }}YANK{{ else }}ADD{{ end }} {{.Namespace}}/{{.Name}}@{{.Version}}"
Expand Down Expand Up @@ -170,12 +171,14 @@ func (r *Cache) Initialize() error {
func (r *Cache) CreateCache() error {
r.logger.Debugf("Creating registry cache for %s/%s", r.url.Host, r.url.Path)

root, err := ioutil.TempDir(filepath.Dir(r.Root), "registry")
registryDir, err := ioutil.TempDir(filepath.Dir(r.Root), "registry")
if err != nil {
return err
}

repository, err := git.PlainClone(root, false, &git.CloneOptions{
r.RegistryDir = registryDir

repository, err := git.PlainClone(r.RegistryDir, false, &git.CloneOptions{
URL: r.url.String(),
})
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions internal/registry/registry_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func testRegistryCache(t *testing.T, when spec.G, it spec.S) {
err = registryCache.Refresh()
h.AssertError(t, err, "initializing")
})

it.After(func() {
h.AssertNil(t, os.RemoveAll(registryCache.RegistryDir))
})
})
})

Expand All @@ -212,6 +216,10 @@ func testRegistryCache(t *testing.T, when spec.G, it spec.S) {
h.AssertError(t, err, "creating registry cache")
})

it.After(func() {
h.AssertNil(t, os.RemoveAll(registryCache.RegistryDir))
})

when("url is empty string", func() {
it("fails to clone cache", func() {
registryCache.url = &url.URL{}
Expand Down

0 comments on commit 359df6c

Please sign in to comment.