mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
refactor: simplifying code from previous pipe
Removed some things that dont make sense anymore, like log between commits. Refs #284
This commit is contained in:
parent
87d269dc45
commit
29a8ae36be
@ -18,21 +18,18 @@ func (Pipe) Description() string {
|
||||
}
|
||||
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
if ctx.ReleaseNotes != "" {
|
||||
return pipeline.Skip("release notes already provided via --release-notes")
|
||||
}
|
||||
var log string
|
||||
if ctx.Git.CurrentTag == "" {
|
||||
log, err = getChangelog(ctx.Git.Commit)
|
||||
} else {
|
||||
log, err = getChangelog(ctx.Git.CurrentTag)
|
||||
if ctx.Snapshot {
|
||||
return pipeline.Skip("not available for snapshots")
|
||||
}
|
||||
log, err := getChangelog(ctx.Git.CurrentTag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.ReleaseNotes = fmt.Sprintf("## Changelog\n\n%v", log)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,10 @@ package changelog
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/testlib"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -21,6 +20,12 @@ func TestChangelogProvidedViaFlag(t *testing.T) {
|
||||
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
|
||||
}
|
||||
|
||||
func TestSnapshot(t *testing.T) {
|
||||
var ctx = context.New(config.Project{})
|
||||
ctx.Snapshot = true
|
||||
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
|
||||
}
|
||||
|
||||
func TestChangelog(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
@ -57,9 +62,18 @@ func TestChangelogOfFirstRelease(t *testing.T) {
|
||||
var ctx = context.New(config.Project{})
|
||||
ctx.Git.CurrentTag = "v0.0.1"
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
assert.Equal(t, "v0.0.1", ctx.Git.CurrentTag)
|
||||
assert.Contains(t, ctx.ReleaseNotes, "## Changelog")
|
||||
for _, msg := range msgs {
|
||||
assert.Contains(t, ctx.ReleaseNotes, msg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChangelogNoTags(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitCommit(t, "first")
|
||||
var ctx = context.New(config.Project{})
|
||||
assert.Error(t, Pipe{}.Run(ctx))
|
||||
assert.Empty(t, ctx.ReleaseNotes)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user