From 306999b78bf8507b0fa2e0fb52582d90a0f0bd1f Mon Sep 17 00:00:00 2001 From: Brian Strauch Date: Fri, 9 Feb 2024 03:12:02 -0800 Subject: [PATCH] fix: sort order of brew artifacts (#4617) Fix the order in which brew artifacts are sorted. * The order occasionally switches, which results in a larger diff: https://github.com/confluentinc/homebrew-tap/pull/41 * The artifacts are already grouped by OS before `lessFnFor()` is called, so `list[i].OS > list[j].OS` always evaluates to `false` and the order remains unchanged. This PR removes that statement. * It looks like a `map` is used earlier, while filtering the artifacts, which might explain why the order occasionally switches. * Update the remaining statement in `lessFnFor()` to actually use `<` as the function suggests. --- internal/pipe/brew/brew.go | 2 +- .../v1.rb.golden | 18 +++++++++--------- .../v2.rb.golden | 18 +++++++++--------- .../v3.rb.golden | 18 +++++++++--------- .../v4.rb.golden | 18 +++++++++--------- .../multiple_armv5.rb.golden | 8 ++++---- .../multiple_armv6.rb.golden | 8 ++++---- .../multiple_armv7.rb.golden | 8 ++++---- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/internal/pipe/brew/brew.go b/internal/pipe/brew/brew.go index 4e99f3e1a..efd2500d2 100644 --- a/internal/pipe/brew/brew.go +++ b/internal/pipe/brew/brew.go @@ -466,7 +466,7 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.ReleaseURLTemp } func lessFnFor(list []releasePackage) func(i, j int) bool { - return func(i, j int) bool { return list[i].OS > list[j].OS && list[i].Arch > list[j].Arch } + return func(i, j int) bool { return list[i].Arch < list[j].Arch } } func split(s string) []string { diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v1.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v1.rb.golden index cd04377ac..dc4407f00 100644 --- a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v1.rb.golden +++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v1.rb.golden @@ -20,19 +20,19 @@ class V1 < Formula end on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/arm64.tar.gz" - sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - - def install - bin.install "foo" - man1.install "./man/foo.1.gz" - end - end if Hardware::CPU.intel? url "https://dummyhost/download/v1.0.1/amd64v2.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install + bin.install "foo" + man1.install "./man/foo.1.gz" + end + end + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/arm64.tar.gz" + sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install bin.install "foo" man1.install "./man/foo.1.gz" diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v2.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v2.rb.golden index 773e9a479..7d80ad679 100644 --- a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v2.rb.golden +++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v2.rb.golden @@ -20,19 +20,19 @@ class V2 < Formula end on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/arm64.tar.gz" - sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - - def install - bin.install "foo" - man1.install "./man/foo.1.gz" - end - end if Hardware::CPU.intel? url "https://dummyhost/download/v1.0.1/amd64v2.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install + bin.install "foo" + man1.install "./man/foo.1.gz" + end + end + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/arm64.tar.gz" + sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install bin.install "foo" man1.install "./man/foo.1.gz" diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v3.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v3.rb.golden index 58af4e162..8d8805ea0 100644 --- a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v3.rb.golden +++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v3.rb.golden @@ -20,19 +20,19 @@ class V3 < Formula end on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/arm64.tar.gz" - sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - - def install - bin.install "foo" - man1.install "./man/foo.1.gz" - end - end if Hardware::CPU.intel? url "https://dummyhost/download/v1.0.1/amd64v3.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install + bin.install "foo" + man1.install "./man/foo.1.gz" + end + end + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/arm64.tar.gz" + sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install bin.install "foo" man1.install "./man/foo.1.gz" diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v4.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v4.rb.golden index 1bbd383ef..432127327 100644 --- a/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v4.rb.golden +++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleAmd64Versions/v4.rb.golden @@ -20,19 +20,19 @@ class V4 < Formula end on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/arm64.tar.gz" - sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - - def install - bin.install "foo" - man1.install "./man/foo.1.gz" - end - end if Hardware::CPU.intel? url "https://dummyhost/download/v1.0.1/amd64v3.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install + bin.install "foo" + man1.install "./man/foo.1.gz" + end + end + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/arm64.tar.gz" + sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + def install bin.install "foo" man1.install "./man/foo.1.gz" diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden index 91e140d6e..3003afab1 100644 --- a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden +++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden @@ -30,16 +30,16 @@ class MultipleArmv5 < Formula end on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/arm64.tar.gz" + if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/armv5.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" def install bin.install "multiple_armv5" end end - if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/armv5.tar.gz" + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/arm64.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" def install diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden index 70768aa88..a92486f2e 100644 --- a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden +++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden @@ -30,16 +30,16 @@ class MultipleArmv6 < Formula end on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/arm64.tar.gz" + if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/armv6.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" def install bin.install "multiple_armv6" end end - if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/armv6.tar.gz" + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/arm64.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" def install diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden index 00b14573b..b9810630f 100644 --- a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden +++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden @@ -30,16 +30,16 @@ class MultipleArmv7 < Formula end on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/arm64.tar.gz" + if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/armv7.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" def install bin.install "multiple_armv7" end end - if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? - url "https://dummyhost/download/v1.0.1/armv7.tar.gz" + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://dummyhost/download/v1.0.1/arm64.tar.gz" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" def install