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

feat: removed goreleaser footer on release notes

closes #619
This commit is contained in:
Carlos Alexandro Becker 2018-04-01 13:27:57 -03:00 committed by Carlos Alexandro Becker
parent c0379ed858
commit 3b5a1fd8ce
4 changed files with 10 additions and 49 deletions

View File

@ -2,7 +2,6 @@ package release
import (
"bytes"
"os/exec"
"text/template"
"github.com/goreleaser/goreleaser/context"
@ -11,17 +10,13 @@ import (
const bodyTemplateText = `{{ .ReleaseNotes }}
{{- if .DockerImages }}
{{- with .DockerImages }}
## Docker images
{{ range $element := .DockerImages }}
{{ range $element := . }}
- ` + "`docker pull {{ . -}}`" + `
{{- end -}}
{{- end }}
---
Automated with [GoReleaser](https://github.com/goreleaser)
Built with {{ .GoVersion }}`
{{- end }}`
var bodyTemplate *template.Template
@ -30,26 +25,16 @@ func init() {
}
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
/* #nosec */
bts, err := exec.CommandContext(ctx, "go", "version").CombinedOutput()
if err != nil {
return bytes.Buffer{}, err
}
return describeBodyVersion(ctx, string(bts))
}
func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, error) {
var out bytes.Buffer
var dockers []string
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
dockers = append(dockers, a.Name)
}
err := bodyTemplate.Execute(&out, struct {
ReleaseNotes, GoVersion string
DockerImages []string
ReleaseNotes string
DockerImages []string
}{
ReleaseNotes: ctx.ReleaseNotes,
GoVersion: version,
DockerImages: dockers,
})
return out, err

View File

@ -3,7 +3,6 @@ package release
import (
"flag"
"io/ioutil"
"os"
"testing"
"github.com/goreleaser/goreleaser/config"
@ -15,7 +14,7 @@ import (
var update = flag.Bool("update", false, "update .golden files")
func TestDescribeBody(t *testing.T) {
var changelog = "\nfeature1: description\nfeature2: other description"
var changelog = "feature1: description\nfeature2: other description"
var ctx = context.New(config.Project{})
ctx.ReleaseNotes = changelog
for _, d := range []string{
@ -28,7 +27,7 @@ func TestDescribeBody(t *testing.T) {
Type: artifact.DockerImage,
})
}
out, err := describeBodyVersion(ctx, "go version go1.9 darwin/amd64")
out, err := describeBody(ctx)
assert.NoError(t, err)
var golden = "testdata/release1.golden"
@ -41,11 +40,11 @@ func TestDescribeBody(t *testing.T) {
}
func TestDescribeBodyNoDockerImagesNoBrews(t *testing.T) {
var changelog = "\nfeature1: description\nfeature2: other description"
var changelog = "feature1: description\nfeature2: other description"
var ctx = &context.Context{
ReleaseNotes: changelog,
}
out, err := describeBodyVersion(ctx, "go version go1.9 darwin/amd64")
out, err := describeBody(ctx)
assert.NoError(t, err)
var golden = "testdata/release2.golden"
@ -67,16 +66,3 @@ func TestDontEscapeHTML(t *testing.T) {
assert.NoError(t, err)
assert.Contains(t, out.String(), changelog)
}
func TestGoVersionFails(t *testing.T) {
var path = os.Getenv("PATH")
defer func() {
assert.NoError(t, os.Setenv("PATH", path))
}()
assert.NoError(t, os.Setenv("PATH", ""))
var ctx = &context.Context{
ReleaseNotes: "changelog",
}
_, err := describeBody(ctx)
assert.Error(t, err)
}

View File

@ -1,4 +1,3 @@
feature1: description
feature2: other description
@ -7,7 +6,3 @@ feature2: other description
- `docker pull goreleaser/goreleaser:0.40.0`
- `docker pull goreleaser/goreleaser:latest`
- `docker pull goreleaser/godownloader:v0.1.0`
---
Automated with [GoReleaser](https://github.com/goreleaser)
Built with go version go1.9 darwin/amd64

View File

@ -1,7 +1,2 @@
feature1: description
feature2: other description
---
Automated with [GoReleaser](https://github.com/goreleaser)
Built with go version go1.9 darwin/amd64
feature2: other description