1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fix: brew no token (#1434)

* 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>
This commit is contained in:
Carlos Alexandro Becker 2020-04-12 10:43:33 -03:00 committed by GitHub
parent 3f4afc522a
commit e580a18382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 45 deletions

View File

@ -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 }}",
@ -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)

View File

@ -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()