diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 272ea30ae..d8a2e1882 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -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, diff --git a/pipeline/brew/brew_test.go b/pipeline/brew/brew_test.go index 9f6f78691..1195e4c4f 100644 --- a/pipeline/brew/brew_test.go +++ b/pipeline/brew/brew_test.go @@ -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" diff --git a/pipeline/defaults/defaults.go b/pipeline/defaults/defaults.go index b854509ac..6ba5c8eff 100644 --- a/pipeline/defaults/defaults.go +++ b/pipeline/defaults/defaults.go @@ -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 } diff --git a/pipeline/defaults/defaults_test.go b/pipeline/defaults/defaults_test.go index 70a7ce0cc..f2173c538 100644 --- a/pipeline/defaults/defaults_test.go +++ b/pipeline/defaults/defaults_test.go @@ -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) } diff --git a/pipeline/scoop/scoop.go b/pipeline/scoop/scoop.go index 6d342e4fb..55952bfda 100644 --- a/pipeline/scoop/scoop.go +++ b/pipeline/scoop/scoop.go @@ -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), diff --git a/pipeline/scoop/scoop_test.go b/pipeline/scoop/scoop_test.go index 4adc25685..da8c66a43 100644 --- a/pipeline/scoop/scoop_test.go +++ b/pipeline/scoop/scoop_test.go @@ -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"}, },