Skip to content

Commit ce26b74

Browse files
arjun024ForestEckhardt
authored andcommitted
uniform versioning with/without release assets
A lot of buildpacks that use freezer are versioned x.y.z (x,y,z being whole numbers) but their releases are tagged vX.Y.Z This means that for buildpack releases that have attached assets, freezer packages them with version X.Y.Z and for those without assets, it packages them as vX.Y.Z. This commit trims the v prefix to bring uniformity
1 parent 47db8a7 commit ce26b74

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

remote_fetcher.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"os"
77
"path/filepath"
8+
"strings"
89

910
"github.com/ForestEckhardt/freezer/github"
1011
"github.com/paketo-buildpacks/packit/v2/vacation"
@@ -79,8 +80,9 @@ func (r RemoteFetcher) Get(buildpack RemoteBuildpack) (string, error) {
7980
}
8081

8182
path := cachedEntry.URI
83+
tagName := strings.TrimLeft(release.TagName, "v")
8284

83-
if release.TagName != cachedEntry.Version || !exist {
85+
if tagName != cachedEntry.Version || !exist {
8486
missingReleaseArtifacts := !(len(release.Assets) > 0)
8587
var bundle io.ReadCloser
8688
if missingReleaseArtifacts || buildpack.Offline {
@@ -95,7 +97,7 @@ func (r RemoteFetcher) Get(buildpack RemoteBuildpack) (string, error) {
9597
}
9698
}
9799

98-
path = filepath.Join(buildpackCacheDir, fmt.Sprintf("%s.tgz", release.TagName))
100+
path = filepath.Join(buildpackCacheDir, fmt.Sprintf("%s.tgz", tagName))
99101

100102
if missingReleaseArtifacts || buildpack.Offline {
101103
downloadDir, err := r.fileSystem.TempDir("", buildpack.Repo)
@@ -109,7 +111,7 @@ func (r RemoteFetcher) Get(buildpack RemoteBuildpack) (string, error) {
109111
return "", err
110112
}
111113

112-
err = r.packager.Execute(downloadDir, path, release.TagName, buildpack.Offline)
114+
err = r.packager.Execute(downloadDir, path, tagName, buildpack.Offline)
113115
if err != nil {
114116
return "", err
115117
}
@@ -128,7 +130,7 @@ func (r RemoteFetcher) Get(buildpack RemoteBuildpack) (string, error) {
128130
}
129131

130132
err = r.buildpackCache.Set(key, CacheEntry{
131-
Version: release.TagName,
133+
Version: tagName,
132134
URI: path,
133135
})
134136

0 commit comments

Comments
 (0)