Skip to content

Commit e85b048

Browse files
author
vilmibm
committed
track installed tag name
1 parent 0e2861a commit e85b048

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pkg/cmd/extension/http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type releaseAsset struct {
4747
}
4848

4949
type release struct {
50+
Tag string `json:"tag_name"`
5051
Assets []releaseAsset
5152
}
5253

pkg/cmd/extension/manager.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ func (m *Manager) InstallLocal(dir string) error {
180180
return makeSymlink(dir, targetLink)
181181
}
182182

183-
type BinManifest struct {
183+
type binManifest struct {
184184
Owner string
185185
Name string
186186
Host string
187+
Tag string
187188
// TODO I may end up not using this; just thinking ahead to local installs
188-
// TODO track version
189189
Path string
190190
}
191191

@@ -248,11 +248,12 @@ func (m *Manager) installBin(client *http.Client, repo ghrepo.Interface) error {
248248
return fmt.Errorf("failed to download asset %s: %w", asset.Name, err)
249249
}
250250

251-
manifest := BinManifest{
251+
manifest := binManifest{
252252
Name: name,
253253
Owner: repo.RepoOwner(),
254254
Host: repo.RepoHost(),
255255
Path: binPath,
256+
Tag: r.Tag,
256257
}
257258

258259
bs, err := yaml.Marshal(manifest)

pkg/cmd/extension/manager_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ func TestManager_Install_binary(t *testing.T) {
254254
httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
255255
httpmock.JSONResponse(
256256
release{
257+
Tag: "v1.0.1",
257258
Assets: []releaseAsset{
258259
{
259260
Name: "gh-bin-ext-windows-amd64",
@@ -276,14 +277,15 @@ func TestManager_Install_binary(t *testing.T) {
276277
manifest, err := os.ReadFile(filepath.Join(tempDir, "extensions/gh-bin-ext/manifest.yml"))
277278
assert.NoError(t, err)
278279

279-
var bm BinManifest
280+
var bm binManifest
280281
err = yaml.Unmarshal(manifest, &bm)
281282
assert.NoError(t, err)
282283

283-
assert.Equal(t, BinManifest{
284+
assert.Equal(t, binManifest{
284285
Name: "gh-bin-ext",
285286
Owner: "owner",
286287
Host: "example.com",
288+
Tag: "v1.0.1",
287289
Path: filepath.Join(tempDir, "extensions/gh-bin-ext/gh-bin-ext"),
288290
}, bm)
289291

0 commit comments

Comments
 (0)