Skip to content

Commit

Permalink
fix: brew no token (#1434)
Browse files Browse the repository at this point in the history
* fix: remove useless log

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: brew no token

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: add a warn

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Apr 12, 2020
1 parent 3f4afc5 commit e580a18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 45 deletions.
16 changes: 7 additions & 9 deletions internal/pipe/brew/brew.go
Expand Up @@ -259,13 +259,6 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, tokenType context.TokenT

if cfg.URLTemplate == "" {
switch tokenType {
case context.TokenTypeGitHub:
cfg.URLTemplate = fmt.Sprintf(
"%s/%s/%s/releases/download/{{ .Tag }}/{{ .ArtifactName }}",
ctx.Config.GitHubURLs.Download,
ctx.Config.Release.GitHub.Owner,
ctx.Config.Release.GitHub.Name,
)
case context.TokenTypeGitLab:
cfg.URLTemplate = fmt.Sprintf(
"%s/%s/%s/uploads/{{ .ArtifactUploadHash }}/{{ .ArtifactName }}",
Expand All @@ -274,8 +267,13 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, tokenType context.TokenT
ctx.Config.Release.GitLab.Name,
)
default:
log.WithField("type", tokenType).Info("here")
return result, ErrTokenTypeNotImplementedForBrew
log.Warn("no url_template set and not github/gitlab/gitea token found, defaulting to github url template")
cfg.URLTemplate = fmt.Sprintf(
"%s/%s/%s/releases/download/{{ .Tag }}/{{ .ArtifactName }}",
ctx.Config.GitHubURLs.Download,
ctx.Config.Release.GitHub.Owner,
ctx.Config.Release.GitHub.Name,
)
}
}
url, err := tmpl.New(ctx).WithArtifact(artifact, map[string]string{}).Apply(cfg.URLTemplate)
Expand Down
36 changes: 0 additions & 36 deletions internal/pipe/brew/brew_test.go
Expand Up @@ -660,42 +660,6 @@ func TestRunPipeNoUpload(t *testing.T) {
})
}

func TestRunTokenTypeNotImplementedForBrew(t *testing.T) {
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(t, err)
var ctx = context.New(config.Project{
Dist: folder,
ProjectName: "foo",
Release: config.Release{},
Brews: []config.Homebrew{
{
GitHub: config.Repo{
Owner: "test",
Name: "test",
},
},
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.1"}
var path = filepath.Join(folder, "whatever.tar.gz")
_, err = os.Create(path)
assert.NoError(t, err)
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin",
Path: path,
Goos: "darwin",
Goarch: "amd64",
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": "foo",
"Format": "tar.gz",
},
})
client := &DummyClient{}
require.Equal(t, ErrTokenTypeNotImplementedForBrew, Pipe{}.Run(ctx))
testlib.AssertSkipped(t, doPublish(ctx, client))
}

func TestDefault(t *testing.T) {
_, back := testlib.Mktmp(t)
defer back()
Expand Down

0 comments on commit e580a18

Please sign in to comment.