track installed tag name

This commit is contained in:
vilmibm 2021-09-20 17:10:18 -05:00
parent 0e2861a507
commit e85b0480e9
3 changed files with 9 additions and 5 deletions

View file

@ -47,6 +47,7 @@ type releaseAsset struct {
}
type release struct {
Tag string `json:"tag_name"`
Assets []releaseAsset
}

View file

@ -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)

View file

@ -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)