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

fix: global default for github download url

This commit is contained in:
Carlos Alexandro Becker 2018-02-15 00:08:28 -02:00 committed by Carlos Alexandro Becker
parent 18cf651cc9
commit 9dfb8547d4
6 changed files with 13 additions and 11 deletions

View File

@ -158,14 +158,10 @@ func dataFor(ctx *context.Context, client client.Client, artifact artifact.Artif
if err != nil {
return
}
var url = "https://github.com"
if ctx.Config.GitHubURLs.Download != "" {
url = ctx.Config.GitHubURLs.Download
}
var cfg = ctx.Config.Brew
return templateData{
Name: formulaNameFor(ctx.Config.ProjectName),
DownloadURL: url,
DownloadURL: ctx.Config.GitHubURLs.Download,
Desc: cfg.Description,
Homepage: cfg.Homepage,
Repo: ctx.Config.Release.GitHub,

View File

@ -148,6 +148,7 @@ func TestRunPipe(t *testing.T) {
var distFile = filepath.Join(folder, "run-pipe.rb")
t.Run("default git url", func(tt *testing.T) {
ctx.Config.GitHubURLs.Download = "https://github.com"
assert.NoError(tt, doRun(ctx, client))
assert.True(tt, client.CreatedFile)
var golden = "testdata/run_pipe.rb.golden"

View File

@ -58,5 +58,8 @@ func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.ProjectName == "" {
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
}
if ctx.Config.GitHubURLs.Download == "" {
ctx.Config.GitHubURLs.Download = "https://github.com"
}
return nil
}

View File

@ -36,6 +36,7 @@ func TestFillBasicData(t *testing.T) {
assert.Equal(t, "tar.gz", ctx.Config.Archive.Format)
assert.Contains(t, ctx.Config.Brew.Install, "bin.install \"goreleaser\"")
assert.Empty(t, ctx.Config.Dockers)
assert.Equal(t, "https://github.com", ctx.Config.GitHubURLs.Download)
assert.NotEmpty(
t,
ctx.Config.Archive.NameTemplate,
@ -53,6 +54,9 @@ func TestFillPartial(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{
GitHubURLs: config.GitHubURLs{
Download: "https://github.company.com",
},
Dist: "disttt",
Release: config.Release{
GitHub: config.Repo{
@ -89,4 +93,5 @@ func TestFillPartial(t *testing.T) {
assert.NotEmpty(t, ctx.Config.Dockers[0].Dockerfile)
assert.Empty(t, ctx.Config.Dockers[0].Goarm)
assert.Equal(t, "disttt", ctx.Config.Dist)
assert.NotEqual(t, "https://github.com", ctx.Config.GitHubURLs.Download)
}

View File

@ -100,12 +100,6 @@ type Resource struct {
}
func buildManifest(ctx *context.Context, client client.Client, artifacts []artifact.Artifact) (result bytes.Buffer, err error) {
var githubURL = "https://github.com"
// TODO: Make this default global
if ctx.Config.GitHubURLs.Download != "" {
githubURL = ctx.Config.GitHubURLs.Download
}
manifest := Manifest{
Version: ctx.Version,
Architecture: make(map[string]Resource),

View File

@ -389,6 +389,9 @@ func Test_buildManifest(t *testing.T) {
Version: "1.0.1",
Artifacts: artifact.New(),
Config: config.Project{
GitHubURLs: config.GitHubURLs{
Download: "https://github.com",
},
Builds: []config.Build{
{Binary: "test"},
},