Repository: goreleaser/goreleaser
Pull request #2530 (2021-09-28 03:13:04)

refactor: improve brew templates
based on #2509

added @dirien  as co-author as its based on their code :)


main idea was to get rid of that gigantic switch and simplify the template a bit

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2530?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#2530](https://codecov.io/gh/goreleaser/goreleaser/pull/2530?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (800206b) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/3e3846a04dfc76a1c1b332c6b3debafd64bb4b87?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (3e3846a) will **decrease** coverage by `0.01%`.
> The diff coverage is `89.47%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2530/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)](https://codecov.io/gh/goreleaser/goreleaser/pull/2530?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)

```diff
@@            Coverage Diff             @@
##           master    #2530      +/-   ##
==========================================
- Coverage   83.45%   83.44%   -0.02%     
==========================================
  Files          93       93              
  Lines        6444     6432      -12     
==========================================
- Hits         5378     5367      -11     
+ Misses        910      908       -2     
- Partials      156      157       +1     
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/2530?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) | Coverage Δ | |
|---|---|---|
| [internal/pipe/brew/brew.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2530/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-aW50ZXJuYWwvcGlwZS9icmV3L2JyZXcuZ28=) | `81.99% <89.47%> (-0.43%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2530?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2530?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Last update [3e3846a...800206b](https://codecov.io/gh/goreleaser/goreleaser/pull/2530?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).


Patch:
diff --git a/internal/pipe/brew/brew.go b/internal/pipe/brew/brew.go
index a0759403..9f4ac5ed 100644
--- a/internal/pipe/brew/brew.go
+++ b/internal/pipe/brew/brew.go
@@ -8,6 +8,7 @@ import (
 	"os"
 	"path"
 	"path/filepath"
+	"sort"
 	"strings"
 	"text/template"
 
@@ -226,15 +227,7 @@ func buildFormula(ctx *context.Context, brew config.Homebrew, client client.Clie
 	return doBuildFormula(ctx, data)
 }
 
-func fixDataDownloads(data templateData) templateData {
-	data.HasMacOSDownloads = data.MacOSAmd64.DownloadURL != "" || data.MacOSArm64.DownloadURL != ""
-	data.HasLinuxDownloads = data.LinuxAmd64.DownloadURL != "" || data.LinuxArm64.DownloadURL != "" || data.LinuxArm.DownloadURL != ""
-	return data
-}
-
 func doBuildFormula(ctx *context.Context, data templateData) (string, error) {
-	data = fixDataDownloads(data)
-
 	t, err := template.
 		New(data.Name).
 		Funcs(template.FuncMap{
@@ -274,23 +267,23 @@ func doBuildFormula(ctx *context.Context, data templateData) (string, error) {
 
 func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifacts []*artifact.Artifact) (templateData, error) {
 	result := templateData{
-		Name:             formulaNameFor(cfg.Name),
-		Desc:             cfg.Description,
-		Homepage:         cfg.Homepage,
-		Version:          ctx.Version,
-		License:          cfg.License,
-		Caveats:          split(cfg.Caveats),
-		Dependencies:     cfg.Dependencies,
-		Conflicts:        cfg.Conflicts,
-		Plist:            cfg.Plist,
-		Install:          split(cfg.Install),
-		PostInstall:      cfg.PostInstall,
-		Tests:            split(cfg.Test),
-		DownloadStrategy: cfg.DownloadStrategy,
-		CustomRequire:    cfg.CustomRequire,
-		CustomBlock:      split(cfg.CustomBlock),
+		Name:          formulaNameFor(cfg.Name),
+		Desc:          cfg.Description,
+		Homepage:      cfg.Homepage,
+		Version:       ctx.Version,
+		License:       cfg.License,
+		Caveats:       split(cfg.Caveats),
+		Dependencies:  cfg.Dependencies,
+		Conflicts:     cfg.Conflicts,
+		Plist:         cfg.Plist,
+		Install:       split(cfg.Install),
+		PostInstall:   cfg.PostInstall,
+		Tests:         split(cfg.Test),
+		CustomRequire: cfg.CustomRequire,
+		CustomBlock:   split(cfg.CustomBlock),
 	}
 
+	counts := map[string]int{}
 	for _, artifact := range artifacts {
 		sum, err := artifact.Checksum("sha256")
 		if err != nil {
@@ -307,52 +300,45 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa
 			}
 			cfg.URLTemplate = url
 		}
+
 		url, err := tmpl.New(ctx).WithArtifact(artifact, map[string]string{}).Apply(cfg.URLTemplate)
 		if err != nil {
 			return result, err
 		}
-		down := downloadable{
-			DownloadURL: url,
-			SHA256:      sum,
+
+		pkg := releasePackage{
+			DownloadURL:      url,
+			SHA256:           sum,
+			OS:               artifact.Goos,
+			Arch:             artifact.Goarch,
+			DownloadStrategy: cfg.DownloadStrategy,
 		}
-		// TODO: refactor
-		if artifact.Goos == "darwin" { // nolint: nestif
-			switch artifact.Goarch {
-			case "amd64":
-				if result.MacOSAmd64.DownloadURL != "" {
-					return result, ErrMultipleArchivesSameOS
-				}
-				result.MacOSAmd64 = down
-			case "arm64":
-				if result.MacOSArm64.DownloadURL != "" {
-					return result, ErrMultipleArchivesSameOS
-				}
-				result.MacOSArm64 = down
-			}
-		} else if artifact.Goos == "linux" {
-			switch artifact.Goarch {
-			case "amd64":
-				if result.LinuxAmd64.DownloadURL != "" {
-					return result, ErrMultipleArchivesSameOS
-				}
-				result.LinuxAmd64 = down
-			case "arm":
-				if result.LinuxArm.DownloadURL != "" {
-					return result, ErrMultipleArchivesSameOS
-				}
-				result.LinuxArm = down
-			case "arm64":
-				if result.LinuxArm64.DownloadURL != "" {
-					return result, ErrMultipleArchivesSameOS
-				}
-				result.LinuxArm64 = down
-			}
+
+		counts[pkg.OS+pkg.Arch]++
+
+		switch pkg.OS {
+		case "darwin":
+			result.MacOSPackages = append(result.MacOSPackages, pkg)
+		case "linux":
+			result.LinuxPackages = append(result.LinuxPackages, pkg)
 		}
 	}
 
+	for _, v := range counts {
+		if v > 1 {
+			return result, ErrMultipleArchivesSameOS
+		}
+	}
+
+	sort.Slice(result.LinuxPackages, lessFnFor(result.LinuxPackages))
+	sort.Slice(result.MacOSPackages, lessFnFor(result.MacOSPackages))
 	return result, nil
 }
 
+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 }
+}
+
 func split(s string) []string {
 	strings := strings.Split(strings.TrimSpace(s), "\n")
 	if len(strings) == 1 && strings[0] == "" {
diff --git a/internal/pipe/brew/template.go b/internal/pipe/brew/template.go
index 0cb28c03..c85ede8e 100644
--- a/internal/pipe/brew/template.go
+++ b/internal/pipe/brew/template.go
@@ -3,33 +3,30 @@ package brew
 import "github.com/goreleaser/goreleaser/pkg/config"
 
 type templateData struct {
-	Name              string
-	Desc              string
-	Homepage          string
-	Version           string
-	License           string
-	Caveats           []string
-	Plist             string
-	DownloadStrategy  string
-	Install           []string
-	PostInstall       string
-	Dependencies      []config.HomebrewDependency
-	Conflicts         []string
-	Tests             []string
-	CustomRequire     string
-	CustomBlock       []string
-	MacOSAmd64        downloadable
-	MacOSArm64        downloadable
-	LinuxAmd64        downloadable
-	LinuxArm          downloadable
-	LinuxArm64        downloadable
-	HasMacOSDownloads bool
-	HasLinuxDownloads bool
+	Name          string
+	Desc          string
+	Homepage      string
+	Version       string
+	License       string
+	Caveats       []string
+	Plist         string
+	Install       []string
+	PostInstall   string
+	Dependencies  []config.HomebrewDependency
+	Conflicts     []string
+	Tests         []string
+	CustomRequire string
+	CustomBlock   []string
+	LinuxPackages []releasePackage
+	MacOSPackages []releasePackage
 }
 
-type downloadable struct {
-	DownloadURL string
-	SHA256      string
+type releasePackage struct {
+	DownloadURL      string
+	SHA256           string
+	OS               string
+	Arch             string
+	DownloadStrategy string
 }
 
 const formulaTemplate = `# typed: false
@@ -47,58 +44,50 @@ class {{ .Name }} < Formula
   license "{{ .License }}"
   {{ end -}}
   bottle :unneeded
-  {{- if and (not .HasLinuxDownloads) .HasMacOSDownloads }}
+  {{- if and (not .LinuxPackages) .MacOSPackages }}
   depends_on :macos
   {{- end }}
-  {{- if and (not .HasMacOSDownloads) .HasLinuxDownloads }}
+  {{- if and (not .MacOSPackages) .LinuxPackages }}
   depends_on :linux
   {{- end }}
   {{- printf "\n" }}
 
-  {{- if .HasMacOSDownloads }}
+  {{- if .MacOSPackages }}
   on_macos do
-    {{- if .MacOSAmd64.DownloadURL }}
+  {{- range $element := .MacOSPackages }}
+    {{- if eq $element.Arch "amd64" }}
     if Hardware::CPU.intel?
-      url "{{ .MacOSAmd64.DownloadURL }}"
-      {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
-      sha256 "{{ .MacOSAmd64.SHA256 }}"
-    end
     {{- end }}
-    {{- if .MacOSArm64.DownloadURL }}
+    {{- if eq $element.Arch "arm64" }}
     if Hardware::CPU.arm?
-      url "{{ .MacOSArm64.DownloadURL }}"
+    {{- end}}
+      url "{{ $element.DownloadURL }}"
       {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
-      sha256 "{{ .MacOSArm64.SHA256 }}"
+      sha256 "{{ $element.SHA256 }}"
     end
-    {{- end }}
+  {{- end }}
   end
   {{- end }}
 
-  {{- if and .HasMacOSDownloads .HasLinuxDownloads }}{{ printf "\n" }}{{ end }}
+  {{- if and .MacOSPackages .LinuxPackages }}{{ printf "\n" }}{{ end }}
 
-  {{- if .HasLinuxDownloads }}
+  {{- if .LinuxPackages }}
   on_linux do
-    {{- if .LinuxAmd64.DownloadURL }}
+  {{- range $element := .LinuxPackages }}
+    {{- if eq $element.Arch "amd64" }}
     if Hardware::CPU.intel?
-      url "{{ .LinuxAmd64.DownloadURL }}"
-      {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
-      sha256 "{{ .LinuxAmd64.SHA256 }}"
-    end
     {{- end }}
-    {{- if .LinuxArm.DownloadURL }}
+    {{- if eq $element.Arch "arm" }}
     if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
-      url "{{ .LinuxArm.DownloadURL }}"
-      {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
-      sha256 "{{ .LinuxArm.SHA256 }}"
-    end
     {{- end }}
-    {{- if .LinuxArm64.DownloadURL }}
+    {{- if eq $element.Arch "arm64" }}
     if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
-      url "{{ .LinuxArm64.DownloadURL }}"
+    {{- end }}
+      url "{{ $element.DownloadURL }}"
       {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
-      sha256 "{{ .LinuxArm64.SHA256 }}"
+      sha256 "{{ $element.SHA256 }}"
     end
-    {{- end }}
+  {{- end }}
   end
   {{- end }}
 


Test patch:
diff --git a/internal/pipe/brew/brew_test.go b/internal/pipe/brew/brew_test.go
index 90e7f1e2..955b037e 100644
--- a/internal/pipe/brew/brew_test.go
+++ b/internal/pipe/brew/brew_test.go
@@ -43,25 +43,39 @@ func TestSimpleName(t *testing.T) {
 var defaultTemplateData = templateData{
 	Desc:     "Some desc",
 	Homepage: "https://google.com",
-	MacOSAmd64: downloadable{
-		DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz",
-		SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
-	},
-	MacOSArm64: downloadable{
-		DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz",
-		SHA256:      "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd",
-	},
-	LinuxAmd64: downloadable{
-		DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
-		SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
-	},
-	LinuxArm: downloadable{
-		DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz",
-		SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
+	LinuxPackages: []releasePackage{
+		{
+			DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
+			SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
+			OS:          "linux",
+			Arch:        "amd64",
+		},
+		{
+			DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz",
+			SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
+			OS:          "linux",
+			Arch:        "arm",
+		},
+		{
+			DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz",
+			SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
+			OS:          "linux",
+			Arch:        "arm64",
+		},
 	},
-	LinuxArm64: downloadable{
-		DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz",
-		SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
+	MacOSPackages: []releasePackage{
+		{
+			DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz",
+			SHA256:      "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
+			OS:          "darwin",
+			Arch:        "amd64",
+		},
+		{
+			DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz",
+			SHA256:      "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd",
+			OS:          "darwin",
+			Arch:        "arm64",
+		},
 	},
 	Name:    "Test",
 	Version: "0.1.3",
@@ -98,8 +112,19 @@ func TestFullFormulae(t *testing.T) {
 
 func TestFullFormulaeLinuxOnly(t *testing.T) {
 	data := defaultTemplateData
-	data.MacOSAmd64 = downloadable{}
-	data.MacOSArm64 = downloadable{}
+	data.MacOSPackages = []releasePackage{}
+	data.Install = []string{`bin.install "test"`}
+	formulae, err := doBuildFormula(context.New(config.Project{
+		ProjectName: "foo",
+	}), data)
+	require.NoError(t, err)
+
+	golden.RequireEqualRb(t, []byte(formulae))
+}
+
+func TestFullFormulaeMacOSOnly(t *testing.T) {
+	data := defaultTemplateData
+	data.LinuxPackages = []releasePackage{}
 	data.Install = []string{`bin.install "test"`}
 	formulae, err := doBuildFormula(context.New(config.Project{
 		ProjectName: "foo",
diff --git a/internal/pipe/brew/testdata/TestFullFormulaeMacOSOnly.rb.golden b/internal/pipe/brew/testdata/TestFullFormulaeMacOSOnly.rb.golden
new file mode 100644
index 00000000..5446eb5a
--- /dev/null
+++ b/internal/pipe/brew/testdata/TestFullFormulaeMacOSOnly.rb.golden
@@ -0,0 +1,26 @@
+# typed: false
+# frozen_string_literal: true
+
+# This file was generated by GoReleaser. DO NOT EDIT.
+class Test < Formula
+  desc "Some desc"
+  homepage "https://google.com"
+  version "0.1.3"
+  bottle :unneeded
+  depends_on :macos
+
+  on_macos do
+    if Hardware::CPU.intel?
+      url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"
+      sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"
+    end
+    if Hardware::CPU.arm?
+      url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz"
+      sha256 "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd"
+    end
+  end
+
+  def install
+    bin.install "test"
+  end
+end
diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden
index cdd0d2e9..a9756d92 100644
--- a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden
+++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv5.rb.golden
@@ -16,14 +16,14 @@ class MultipleArmv5 < Formula
   end
 
   on_linux do
-    if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
-      url "https://dummyhost/download/v1.0.1/armv5.tar.gz"
-      sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
-    end
     if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
       url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
       sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
     end
+    if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
+      url "https://dummyhost/download/v1.0.1/armv5.tar.gz"
+      sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
+    end
   end
 
   depends_on "zsh"
diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden
index 40f06a96..71588bcd 100644
--- a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden
+++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv6.rb.golden
@@ -16,14 +16,14 @@ class MultipleArmv6 < Formula
   end
 
   on_linux do
-    if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
-      url "https://dummyhost/download/v1.0.1/armv6.tar.gz"
-      sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
-    end
     if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
       url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
       sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
     end
+    if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
+      url "https://dummyhost/download/v1.0.1/armv6.tar.gz"
+      sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
+    end
   end
 
   depends_on "zsh"
diff --git a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden
index 97e11f66..95100af0 100644
--- a/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden
+++ b/internal/pipe/brew/testdata/TestRunPipeForMultipleArmVersions/multiple_armv7.rb.golden
@@ -16,14 +16,14 @@ class MultipleArmv7 < Formula
   end
 
   on_linux do
-    if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
-      url "https://dummyhost/download/v1.0.1/armv7.tar.gz"
-      sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
-    end
     if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
       url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
       sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
     end
+    if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
+      url "https://dummyhost/download/v1.0.1/armv7.tar.gz"
+      sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
+    end
   end
 
   depends_on "zsh"