Repository: goreleaser/goreleaser
Pull request #1568 (2020-05-26 14:20:57)

fix: Brew versioned formulae now supported
<!--

Hi, thanks for contributing!

Please make sure you read our CONTRIBUTING guide.

Please fill the fields above:

-->

<!-- If applied, this commit will... -->
Will replace `@` for `AT` in brew formulae name.

<!-- Why is this change being made? -->
Allow for Brew versioned releases (eg: foo@1). See how [awscli](https://github.com/Homebrew/homebrew-core/blob/master/Formula/awscli.rb#L1) and [awscli@1](https://github.com/Homebrew/homebrew-core/blob/master/Formula/awscli%401.rb#L1) do it.

<!-- # Provide links to any relevant tickets, URLs or other resources -->
- Fixes https://github.com/goreleaser/goreleaser/issues/1537
- https://github.com/Homebrew/homebrew-core/blob/master/Formula/awscli.rb#L1
- https://github.com/Homebrew/homebrew-core/blob/master/Formula/awscli%401.rb#L1


vercel-for-github[bot]: 
This pull request is being automatically deployed with Vercel ([learn more](https://zeit.ink/github-learn-more)).
To see the status of your deployment, click on the icon next to each commit.
	
caarlos0: Awesome, thanks!
codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1568?src=pr&el=h1) Report
> Merging [#1568](https://codecov.io/gh/goreleaser/goreleaser/pull/1568?src=pr&el=desc) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/5f41640978a306ea60c7478ebd65bd152ec3c467&el=desc) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/1568/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN)](https://codecov.io/gh/goreleaser/goreleaser/pull/1568?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1568   +/-   ##
=======================================
  Coverage   85.58%   85.59%           
=======================================
  Files          70       70           
  Lines        3851     3852    +1     
=======================================
+ Hits         3296     3297    +1     
  Misses        459      459           
  Partials       96       96           
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/1568?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [internal/pipe/brew/brew.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1568/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9icmV3L2JyZXcuZ28=) | `88.23% <100.00%> (+0.06%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1568?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1568?src=pr&el=footer). Last update [5f41640...1620a12](https://codecov.io/gh/goreleaser/goreleaser/pull/1568?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/internal/pipe/brew/brew.go b/internal/pipe/brew/brew.go
index d0046b34..36fa5d4a 100644
--- a/internal/pipe/brew/brew.go
+++ b/internal/pipe/brew/brew.go
@@ -309,5 +309,6 @@ func split(s string) []string {
 func formulaNameFor(name string) string {
 	name = strings.Replace(name, "-", " ", -1)
 	name = strings.Replace(name, "_", " ", -1)
+	name = strings.Replace(name, "@", "AT", -1)
 	return strings.Replace(strings.Title(name), " ", "", -1)
 }


Test patch:
diff --git a/internal/pipe/brew/brew_test.go b/internal/pipe/brew/brew_test.go
index f0b5d801..b4c4938b 100644
--- a/internal/pipe/brew/brew_test.go
+++ b/internal/pipe/brew/brew_test.go
@@ -29,6 +29,10 @@ func TestNameWithUnderline(t *testing.T) {
 	assert.Equal(t, formulaNameFor("some_binary"), "SomeBinary")
 }
 
+func TestNameWithAT(t *testing.T) {
+	assert.Equal(t, formulaNameFor("some_binary@1"), "SomeBinaryAT1")
+}
+
 func TestSimpleName(t *testing.T) {
 	assert.Equal(t, formulaNameFor("binary"), "Binary")
 }