Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to specify version of brew deps #3319

Merged
merged 8 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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