Skip to content

Commit db8a60e

Browse files
simonchrzandrew
authored andcommitted
Drop the Homebrew sibling formulae filter
git-pkgs/registries#120 stops listing versioned formulae as versions.
1 parent 2a8ceb9 commit db8a60e

2 files changed

Lines changed: 3 additions & 37 deletions

File tree

‎internal/mirror/brew_test.go‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ package mirror
33
import (
44
"context"
55
"errors"
6-
"net/http"
7-
"net/http/httptest"
86
"strings"
97
"sync"
108
"testing"
119

1210
"github.com/git-pkgs/proxy/internal/handler"
13-
"github.com/git-pkgs/registries"
1411
)
1512

1613
// fakeBottles resolves every formula version to homebrew/core/<name> tagged
@@ -96,28 +93,3 @@ func TestMirrorBrewFailures(t *testing.T) {
9693
t.Errorf("unknown formula: %+v, mirrored %v", progress, images.refs)
9794
}
9895
}
99-
100-
// The Homebrew client lists a formula's versioned siblings as versions;
101-
// listing keeps only the formula's own version.
102-
func TestListBrewVersionsSkipsSiblingFormulae(t *testing.T) {
103-
api := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
104-
if r.URL.Path != "/api/formula/openssl@3.json" {
105-
http.NotFound(w, r)
106-
return
107-
}
108-
_, _ = w.Write([]byte(`{"name":"openssl@3","versions":{"stable":"3.5.9"},
109-
"versioned_formulae":["openssl@3.6","openssl@3.0"]}`))
110-
}))
111-
defer api.Close()
112-
lister := RegistryVersions{
113-
Client: registries.NewClient(registries.WithHTTPClient(api.Client())),
114-
URL: func(string, string) (string, error) { return api.URL, nil },
115-
}
116-
versions, err := lister.ListVersions(context.Background(), "brew", "openssl@3")
117-
if err != nil {
118-
t.Fatal(err)
119-
}
120-
if len(versions) != 1 || versions[0] != "3.5.9" {
121-
t.Errorf("versions = %v, want [3.5.9]", versions)
122-
}
123-
}

‎internal/mirror/versions.go‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,9 @@ func (r RegistryVersions) ListVersions(ctx context.Context, ecosystem, name stri
4242
if err != nil {
4343
return nil, err
4444
}
45-
result := make([]string, 0, len(versions))
46-
for _, v := range versions {
47-
// The Homebrew client also lists a formula's versioned siblings,
48-
// openssl@3.6 for openssl@3, as versions marked with the sibling's
49-
// name. They are other formulae, not versions of this one.
50-
if _, sibling := v.Metadata["formula"]; sibling {
51-
continue
52-
}
53-
result = append(result, v.Number)
45+
result := make([]string, len(versions))
46+
for i, v := range versions {
47+
result[i] = v.Number
5448
}
5549
return result, nil
5650
}

0 commit comments

Comments
 (0)