Skip to content

Commit

Permalink
feat: allow to specify version of brew deps (#3319)
Browse files Browse the repository at this point in the history
* feat: add version for homebrew dependencies

* resolve conflicts

* resolve conflicts

* feat: allow to specify version of brew deps

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>

* docs: brew

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Purushotham <purushotham@hasura.io>
  • Loading branch information
caarlos0 and purush7 committed Aug 18, 2022
1 parent dcd402c commit 6d000e5
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 19 deletions.
24 changes: 14 additions & 10 deletions internal/pipe/brew/brew_test.go
Expand Up @@ -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: `<xml>whatever</xml>`,
Dependencies: []config.HomebrewDependency{{Name: "zsh", Type: "optional"}, {Name: "bash"}},
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: `<xml>whatever</xml>`,
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",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pipe/brew/template.go
Expand Up @@ -48,7 +48,7 @@ class {{ .Name }} < Formula
{{- with .Dependencies }}
{{ range $index, $element := . }}
depends_on "{{ .Name }}"
{{- if .Type }} => :{{ .Type }}{{- end }}
{{- if .Type }} => :{{ .Type }}{{- else if .Version }} => "{{ .Version }}"{{- end }}
{{- end }}
{{- end -}}
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion internal/pipe/brew/testdata/TestFullPipe/default.rb.golden
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/config/config.go
Expand Up @@ -82,8 +82,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.
Expand Down
7 changes: 7 additions & 0 deletions www/docs/customization/homebrew.md
Expand Up @@ -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:
Expand Down

0 comments on commit 6d000e5

Please sign in to comment.