From 65f181ffa966034aa458bbab65da66d83467595c Mon Sep 17 00:00:00 2001 From: Ram Damera Date: Fri, 27 Feb 2026 15:21:05 +0530 Subject: [PATCH 1/2] use outer scoped error and fix missing ctx in tests --- install/install.go | 8 ++++---- install/install_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/install/install.go b/install/install.go index eab1bf2..1bff6c9 100644 --- a/install/install.go +++ b/install/install.go @@ -163,7 +163,7 @@ func FromRepo(ctx context.Context, pi goolib.PackageInfo, repo, cache string, rm logger.Infof("Starting install of %s.%s.%s", pi.Name, pi.Arch, pi.Ver) fmt.Printf("Installing %s.%s.%s and dependencies...\n", pi.Name, pi.Arch, pi.Ver) var rs goolib.RepoSpec - var err error + var rsErr error // If no version is specified, resolve the latest version handling both // direct matches and providers. if pi.Ver == "" { @@ -180,11 +180,11 @@ func FromRepo(ctx context.Context, pi goolib.PackageInfo, repo, cache string, rm } else { // When a specific version is requested, look for an exact match in the repository. // Virtual package resolution is not currently supported for specific versions. - rs, err = client.FindRepoSpec(pi, rm[repo]) + rs, rsErr = client.FindRepoSpec(pi, rm[repo]) } - if err != nil { - return err + if rsErr != nil { + return rsErr } if err := installDeps(ctx, rs.PackageSpec, cache, rm, archs, dbOnly, downloader, db); err != nil { return err diff --git a/install/install_test.go b/install/install_test.go index 3561ef2..b9d6f67 100644 --- a/install/install_test.go +++ b/install/install_test.go @@ -437,7 +437,7 @@ func TestFromRepo_SatisfiedByProvider(t *testing.T) { // We pass empty repo map and downloader because we expect it NOT to try downloading deps // since they are satisfied. - err = installDeps(nil, ps, "", nil, nil, false, nil, db) + err = installDeps(t.Context(), ps, "", nil, nil, false, nil, db) if err != nil { t.Errorf("installDeps failed: %v", err) } @@ -479,7 +479,7 @@ func TestFromRepo_SatisfiedByUninstalledProvider(t *testing.T) { // Verify that dependency resolution succeeds (finding provider_pkg); the download // is expected to fail due to an invalid repository URL. downloader, _ := client.NewDownloader("") - err = installDeps(nil, ps, "", rm, []string{"noarch"}, false, downloader, db) + err = installDeps(t.Context(), ps, "", rm, []string{"noarch"}, false, downloader, db) // We expect an error because download will fail (invalid URL/Source). if err == nil { From 25ee5a9f480b35f9f4335cb2ad452e8761a9db48 Mon Sep 17 00:00:00 2001 From: Ram Damera Date: Thu, 5 Mar 2026 02:26:36 +0530 Subject: [PATCH 2/2] refactor actual package check and obtaining specific version --- install/install.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/install/install.go b/install/install.go index 1bff6c9..598abba 100644 --- a/install/install.go +++ b/install/install.go @@ -162,8 +162,8 @@ func installDeps(ctx context.Context, ps *goolib.PkgSpec, cache string, rm clien func FromRepo(ctx context.Context, pi goolib.PackageInfo, repo, cache string, rm client.RepoMap, archs []string, dbOnly bool, downloader *client.Downloader, db *googetdb.GooDB) error { logger.Infof("Starting install of %s.%s.%s", pi.Name, pi.Arch, pi.Ver) fmt.Printf("Installing %s.%s.%s and dependencies...\n", pi.Name, pi.Arch, pi.Ver) - var rs goolib.RepoSpec - var rsErr error + // When a specific version is requested, look for an exact match in the repository. + // Virtual package resolution is not currently supported for specific versions. // If no version is specified, resolve the latest version handling both // direct matches and providers. if pi.Ver == "" { @@ -176,15 +176,11 @@ func FromRepo(ctx context.Context, pi goolib.PackageInfo, repo, cache string, rm pi.Name = spec.Name pi.Arch = spec.Arch pi.Ver = spec.Version - rs, err = client.FindRepoSpec(goolib.PackageInfo{Name: spec.Name, Arch: spec.Arch, Ver: spec.Version}, rm[repo]) - } else { - // When a specific version is requested, look for an exact match in the repository. - // Virtual package resolution is not currently supported for specific versions. - rs, rsErr = client.FindRepoSpec(pi, rm[repo]) } - if rsErr != nil { - return rsErr + rs, err := client.FindRepoSpec(pi, rm[repo]) + if err != nil { + return err } if err := installDeps(ctx, rs.PackageSpec, cache, rm, archs, dbOnly, downloader, db); err != nil { return err