Skip to content

Commit ff8873d

Browse files
Fix extension install error message showing raw struct instead of owner/repo (cli#12836)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: williammartin <1611510+williammartin@users.noreply.github.com>
1 parent d594c5e commit ff8873d

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

pkg/cmd/extension/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (m *Manager) Install(repo ghrepo.Interface, target string) error {
268268
return err
269269
}
270270
if !hs {
271-
return fmt.Errorf("extension is not installable: no usable release artifact or script found in %s", repo)
271+
return fmt.Errorf("extension is not installable: no usable release artifact or script found in %s", ghrepo.FullName(repo))
272272
}
273273

274274
return m.installGit(repo, target)

pkg/cmd/extension/manager_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,39 @@ func TestManager_Install_git(t *testing.T) {
867867
assert.NoDirExistsf(t, extensionUpdatePath, "update directory should be removed")
868868
}
869869

870+
func TestManager_Install_not_installable(t *testing.T) {
871+
dataDir := t.TempDir()
872+
updateDir := t.TempDir()
873+
874+
reg := httpmock.Registry{}
875+
defer reg.Verify(t)
876+
client := http.Client{Transport: &reg}
877+
878+
ios, _, _, _ := iostreams.Test()
879+
880+
m := newTestManager(dataDir, updateDir, &client, nil, ios)
881+
882+
reg.Register(
883+
httpmock.REST("GET", "repos/owner/gh-some-ext/releases/latest"),
884+
httpmock.JSONResponse(
885+
release{
886+
Assets: []releaseAsset{
887+
{
888+
Name: "not-a-binary",
889+
APIURL: "https://example.com/release/cool",
890+
},
891+
},
892+
}))
893+
reg.Register(
894+
httpmock.REST("GET", "repos/owner/gh-some-ext/contents/gh-some-ext"),
895+
httpmock.StatusStringResponse(404, "not found"))
896+
897+
repo := ghrepo.New("owner", "gh-some-ext")
898+
899+
err := m.Install(repo, "")
900+
assert.EqualError(t, err, "extension is not installable: no usable release artifact or script found in owner/gh-some-ext")
901+
}
902+
870903
func TestManager_Install_git_pinned(t *testing.T) {
871904
dataDir := t.TempDir()
872905
updateDir := t.TempDir()

0 commit comments

Comments
 (0)