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:
parent
3f4afc522a
commit
e580a18382
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user