From e85b0480e90820a52dbbf8748602d67eced01524 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 20 Sep 2021 17:10:18 -0500 Subject: [PATCH] track installed tag name --- pkg/cmd/extension/http.go | 1 + pkg/cmd/extension/manager.go | 7 ++++--- pkg/cmd/extension/manager_test.go | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/extension/http.go b/pkg/cmd/extension/http.go index de6f61e4b..6f93f2303 100644 --- a/pkg/cmd/extension/http.go +++ b/pkg/cmd/extension/http.go @@ -47,6 +47,7 @@ type releaseAsset struct { } type release struct { + Tag string `json:"tag_name"` Assets []releaseAsset } diff --git a/pkg/cmd/extension/manager.go b/pkg/cmd/extension/manager.go index db6ec76ba..05e048588 100644 --- a/pkg/cmd/extension/manager.go +++ b/pkg/cmd/extension/manager.go @@ -180,12 +180,12 @@ func (m *Manager) InstallLocal(dir string) error { return makeSymlink(dir, targetLink) } -type BinManifest struct { +type binManifest struct { Owner string Name string Host string + Tag string // TODO I may end up not using this; just thinking ahead to local installs - // TODO track version Path string } @@ -248,11 +248,12 @@ func (m *Manager) installBin(client *http.Client, repo ghrepo.Interface) error { return fmt.Errorf("failed to download asset %s: %w", asset.Name, err) } - manifest := BinManifest{ + manifest := binManifest{ Name: name, Owner: repo.RepoOwner(), Host: repo.RepoHost(), Path: binPath, + Tag: r.Tag, } bs, err := yaml.Marshal(manifest) diff --git a/pkg/cmd/extension/manager_test.go b/pkg/cmd/extension/manager_test.go index f0a930dcd..8c4ca604e 100644 --- a/pkg/cmd/extension/manager_test.go +++ b/pkg/cmd/extension/manager_test.go @@ -254,6 +254,7 @@ func TestManager_Install_binary(t *testing.T) { httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"), httpmock.JSONResponse( release{ + Tag: "v1.0.1", Assets: []releaseAsset{ { Name: "gh-bin-ext-windows-amd64", @@ -276,14 +277,15 @@ func TestManager_Install_binary(t *testing.T) { manifest, err := os.ReadFile(filepath.Join(tempDir, "extensions/gh-bin-ext/manifest.yml")) assert.NoError(t, err) - var bm BinManifest + var bm binManifest err = yaml.Unmarshal(manifest, &bm) assert.NoError(t, err) - assert.Equal(t, BinManifest{ + assert.Equal(t, binManifest{ Name: "gh-bin-ext", Owner: "owner", Host: "example.com", + Tag: "v1.0.1", Path: filepath.Join(tempDir, "extensions/gh-bin-ext/gh-bin-ext"), }, bm)