From c34f0c648312e49cedff420ea3dd43123f6d003b Mon Sep 17 00:00:00 2001 From: Purushotham Date: Sun, 7 Aug 2022 13:04:38 +0530 Subject: [PATCH 1/5] feat: add version for homebrew dependencies --- internal/pipe/brew/brew_test.go | 2 +- internal/pipe/brew/template.go | 1 + .../pipe/brew/testdata/TestFullPipe/custom_block.rb.golden | 2 +- .../testdata/TestFullPipe/custom_download_strategy.rb.golden | 2 +- .../pipe/brew/testdata/TestFullPipe/custom_require.rb.golden | 2 +- internal/pipe/brew/testdata/TestFullPipe/default.rb.golden | 2 +- .../pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden | 2 +- .../brew/testdata/TestFullPipe/valid_tap_templates.rb.golden | 2 +- pkg/config/config.go | 5 +++-- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/internal/pipe/brew/brew_test.go b/internal/pipe/brew/brew_test.go index 62d6529d4b2..aa674fefc2c 100644 --- a/internal/pipe/brew/brew_test.go +++ b/internal/pipe/brew/brew_test.go @@ -272,7 +272,7 @@ func TestFullPipe(t *testing.T) { Caveats: "don't do this {{ .ProjectName }}", Test: "system \"true\"\nsystem \"#{bin}/foo -h\"", Plist: `whatever`, - Dependencies: []config.HomebrewDependency{{Name: "zsh", Type: "optional"}, {Name: "bash"}}, + Dependencies: []config.HomebrewDependency{{Name: "zsh", Type: "optional"}, {Name: "bash", Version: "3.2.57"}}, Conflicts: []string{"gtk+", "qt"}, Service: "run foo/bar\nkeep_alive true", PostInstall: "system \"echo\"\nsystem \"touch\" \"/tmp/hi\"", diff --git a/internal/pipe/brew/template.go b/internal/pipe/brew/template.go index c66c26f7df7..8f5878db45a 100644 --- a/internal/pipe/brew/template.go +++ b/internal/pipe/brew/template.go @@ -146,6 +146,7 @@ class {{ .Name }} < Formula {{ range $index, $element := . }} depends_on "{{ .Name }}" {{- if .Type }} => :{{ .Type }}{{- end }} + {{- if .Version}} => :{{ .Version }}{{- end }} {{- end }} {{- end -}} diff --git a/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden index 87289275dd7..4eeb10fb946 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden @@ -30,7 +30,7 @@ class CustomBlock < Formula head "https://github.com/caarlos0/test.git" depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => :3.2.57 conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden index 450351e5844..fdd8c0545c1 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden @@ -28,7 +28,7 @@ class CustomDownloadStrategy < Formula end depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => :3.2.57 conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden index baa5b40ebd3..21f94d8c6f8 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden @@ -29,7 +29,7 @@ class CustomRequire < Formula end depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => :3.2.57 conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden index 8501ec49a97..478a850d6dd 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden @@ -28,7 +28,7 @@ class Default < Formula end depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => :3.2.57 conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden index 64378d0a108..63bdd7dc407 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden @@ -28,7 +28,7 @@ class DefaultGitlab < Formula end depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => :3.2.57 conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden index 69dd9e0f8ce..bcabd59672f 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden @@ -28,7 +28,7 @@ class ValidTapTemplates < Formula end depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => :3.2.57 conflicts_with "gtk+" conflicts_with "qt" diff --git a/pkg/config/config.go b/pkg/config/config.go index bec89af9d4d..28b900bc4e4 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -81,8 +81,9 @@ type RepoRef struct { // HomebrewDependency represents Homebrew dependency. type HomebrewDependency struct { - Name string `yaml:"name,omitempty" json:"name,omitempty"` - Type string `yaml:"type,omitempty" json:"type,omitempty"` + Name string `yaml:"name,omitempty" json:"name,omitempty"` + Type string `yaml:"type,omitempty" json:"type,omitempty"` + Version string `yaml:"version,omitempty" json:"version,omitempty"` } // type alias to prevent stack overflowing in the custom unmarshaler. From ba63e14d38f38740d59a1a399514abdcf691843a Mon Sep 17 00:00:00 2001 From: Purushotham Date: Sun, 7 Aug 2022 13:35:48 +0530 Subject: [PATCH 2/5] resolve conflicts --- internal/pipe/brew/template.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/internal/pipe/brew/template.go b/internal/pipe/brew/template.go index a926c463d02..3b976d23d91 100644 --- a/internal/pipe/brew/template.go +++ b/internal/pipe/brew/template.go @@ -49,6 +49,7 @@ class {{ .Name }} < Formula {{ range $index, $element := . }} depends_on "{{ .Name }}" {{- if .Type }} => :{{ .Type }}{{- end }} + {{- if .Version}} => :{{ .Version }}{{- end }} {{- end }} {{- end -}} @@ -149,15 +150,7 @@ class {{ .Name }} < Formula {{- end }} {{- end }} - {{- with .Dependencies }} - {{ range $index, $element := . }} - depends_on "{{ .Name }}" - {{- if .Type }} => :{{ .Type }}{{- end }} - {{- if .Version}} => :{{ .Version }}{{- end }} - {{- end }} - {{- end -}} - - {{- with .Conflicts }} + {{- with .CustomBlock}} {{ range $index, $element := . }} {{ . }} {{- end }} From 451bc3ccb709e111c1e8663df46824c47f120146 Mon Sep 17 00:00:00 2001 From: Purushotham Date: Sun, 7 Aug 2022 13:36:37 +0530 Subject: [PATCH 3/5] resolve conflicts --- internal/pipe/brew/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pipe/brew/template.go b/internal/pipe/brew/template.go index 3b976d23d91..fa9c962eb0e 100644 --- a/internal/pipe/brew/template.go +++ b/internal/pipe/brew/template.go @@ -150,7 +150,7 @@ class {{ .Name }} < Formula {{- end }} {{- end }} - {{- with .CustomBlock}} + {{- with .CustomBlock }} {{ range $index, $element := . }} {{ . }} {{- end }} From c8bc634974cceb84e93ddbef20e74b72b64e740d Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Wed, 17 Aug 2022 22:38:29 -0300 Subject: [PATCH 4/5] feat: allow to specify version of brew deps Signed-off-by: Carlos A Becker --- internal/pipe/brew/brew_test.go | 24 +++++++++++-------- internal/pipe/brew/template.go | 3 +-- .../TestFullPipe/custom_block.rb.golden | 8 ++----- .../custom_download_strategy.rb.golden | 6 ++--- .../TestFullPipe/custom_require.rb.golden | 6 ++--- .../testdata/TestFullPipe/default.rb.golden | 6 ++--- .../TestFullPipe/default_gitlab.rb.golden | 6 ++--- .../valid_tap_templates.rb.golden | 6 ++--- 8 files changed, 27 insertions(+), 38 deletions(-) diff --git a/internal/pipe/brew/brew_test.go b/internal/pipe/brew/brew_test.go index 317b505edf4..38ea0064a3e 100644 --- a/internal/pipe/brew/brew_test.go +++ b/internal/pipe/brew/brew_test.go @@ -268,16 +268,20 @@ func TestFullPipe(t *testing.T) { IDs: []string{ "foo", }, - Description: "Run pipe test formula and FOO={{ .Env.FOO }}", - Caveats: "don't do this {{ .ProjectName }}", - Test: "system \"true\"\nsystem \"#{bin}/foo\", \"-h\"", - Plist: `whatever`, - Dependencies: []config.HomebrewDependency{{Name: "zsh", Type: "optional"}, {Name: "bash", Version: "3.2.57"}}, - Conflicts: []string{"gtk+", "qt"}, - Service: "run foo/bar\nkeep_alive true", - PostInstall: "system \"echo\"\ntouch \"/tmp/hi\"", - Install: `bin.install "{{ .ProjectName }}"`, - Goamd64: "v1", + Description: "Run pipe test formula and FOO={{ .Env.FOO }}", + Caveats: "don't do this {{ .ProjectName }}", + Test: "system \"true\"\nsystem \"#{bin}/foo\", \"-h\"", + Plist: `whatever`, + Dependencies: []config.HomebrewDependency{ + {Name: "zsh", Type: "optional"}, + {Name: "bash", Version: "3.2.57"}, + {Name: "fish", Type: "optional", Version: "v1.2.3"}, + }, + Conflicts: []string{"gtk+", "qt"}, + Service: "run foo/bar\nkeep_alive true", + PostInstall: "system \"echo\"\ntouch \"/tmp/hi\"", + Install: `bin.install "{{ .ProjectName }}"`, + Goamd64: "v1", }, }, }, diff --git a/internal/pipe/brew/template.go b/internal/pipe/brew/template.go index fa9c962eb0e..799ce4b22c9 100644 --- a/internal/pipe/brew/template.go +++ b/internal/pipe/brew/template.go @@ -48,8 +48,7 @@ class {{ .Name }} < Formula {{- with .Dependencies }} {{ range $index, $element := . }} depends_on "{{ .Name }}" - {{- if .Type }} => :{{ .Type }}{{- end }} - {{- if .Version}} => :{{ .Version }}{{- end }} + {{- if .Type }} => :{{ .Type }}{{- else if .Version }} => "{{ .Version }}"{{- end }} {{- end }} {{- end -}} diff --git a/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden index e6ca08f435c..5bef8efc042 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden @@ -8,7 +8,8 @@ class CustomBlock < Formula version "1.0.1" depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => "3.2.57" + depends_on "fish" => :optional depends_on :macos on_macos do @@ -30,11 +31,6 @@ class CustomBlock < Formula end end - head "https://github.com/caarlos0/test.git" - - depends_on "zsh" => :optional - depends_on "bash" => :3.2.57 - conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden index dc1677abc50..90525b1f195 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden @@ -8,7 +8,8 @@ class CustomDownloadStrategy < Formula version "1.0.1" depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => "3.2.57" + depends_on "fish" => :optional depends_on :macos on_macos do @@ -30,9 +31,6 @@ class CustomDownloadStrategy < Formula end end - depends_on "zsh" => :optional - depends_on "bash" => :3.2.57 - conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden index 67e459358ad..6dee341f2aa 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden @@ -9,7 +9,8 @@ class CustomRequire < Formula version "1.0.1" depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => "3.2.57" + depends_on "fish" => :optional depends_on :macos on_macos do @@ -31,9 +32,6 @@ class CustomRequire < Formula end end - depends_on "zsh" => :optional - depends_on "bash" => :3.2.57 - conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden index 6b3518a27d2..d8d4b479ba6 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/default.rb.golden @@ -8,7 +8,8 @@ class Default < Formula version "1.0.1" depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => "3.2.57" + depends_on "fish" => :optional depends_on :macos on_macos do @@ -30,9 +31,6 @@ class Default < Formula end end - depends_on "zsh" => :optional - depends_on "bash" => :3.2.57 - conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden index f3c2a0312c8..23dc20da5d4 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden @@ -8,7 +8,8 @@ class DefaultGitlab < Formula version "1.0.1" depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => "3.2.57" + depends_on "fish" => :optional depends_on :macos on_macos do @@ -30,9 +31,6 @@ class DefaultGitlab < Formula end end - depends_on "zsh" => :optional - depends_on "bash" => :3.2.57 - conflicts_with "gtk+" conflicts_with "qt" diff --git a/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden b/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden index 11401fba04a..28a01583e89 100644 --- a/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden +++ b/internal/pipe/brew/testdata/TestFullPipe/valid_tap_templates.rb.golden @@ -8,7 +8,8 @@ class ValidTapTemplates < Formula version "1.0.1" depends_on "zsh" => :optional - depends_on "bash" + depends_on "bash" => "3.2.57" + depends_on "fish" => :optional depends_on :macos on_macos do @@ -30,9 +31,6 @@ class ValidTapTemplates < Formula end end - depends_on "zsh" => :optional - depends_on "bash" => :3.2.57 - conflicts_with "gtk+" conflicts_with "qt" From 635273fdf7359c3323cb63e63c4832d5cb833e99 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Wed, 17 Aug 2022 22:41:29 -0300 Subject: [PATCH 5/5] docs: brew Signed-off-by: Carlos A Becker --- www/docs/customization/homebrew.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/www/docs/customization/homebrew.md b/www/docs/customization/homebrew.md index 756a7c55a4b..e19e7a63f7c 100644 --- a/www/docs/customization/homebrew.md +++ b/www/docs/customization/homebrew.md @@ -113,6 +113,13 @@ brews: - name: git - name: zsh type: optional + - name: fish + version: v1.2.3 + # if providing both version and type, only the type will be taken into account. + - name: elvish + type: optional + version: v1.2.3 + # Packages that conflict with your package. conflicts: