You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-09-16 09:26:52 +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:
committed by
Carlos Alexandro Becker
parent
87d269dc45
commit
29a8ae36be
@@ -18,21 +18,18 @@ func (Pipe) Description() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
func (Pipe) Run(ctx *context.Context) (err error) {
|
func (Pipe) Run(ctx *context.Context) error {
|
||||||
if ctx.ReleaseNotes != "" {
|
if ctx.ReleaseNotes != "" {
|
||||||
return pipeline.Skip("release notes already provided via --release-notes")
|
return pipeline.Skip("release notes already provided via --release-notes")
|
||||||
}
|
}
|
||||||
var log string
|
if ctx.Snapshot {
|
||||||
if ctx.Git.CurrentTag == "" {
|
return pipeline.Skip("not available for snapshots")
|
||||||
log, err = getChangelog(ctx.Git.Commit)
|
|
||||||
} else {
|
|
||||||
log, err = getChangelog(ctx.Git.CurrentTag)
|
|
||||||
}
|
}
|
||||||
|
log, err := getChangelog(ctx.Git.CurrentTag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ctx.ReleaseNotes = fmt.Sprintf("## Changelog\n\n%v", log)
|
ctx.ReleaseNotes = fmt.Sprintf("## Changelog\n\n%v", log)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,11 +3,10 @@ package changelog
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/goreleaser/goreleaser/config"
|
||||||
|
"github.com/goreleaser/goreleaser/context"
|
||||||
"github.com/goreleaser/goreleaser/internal/testlib"
|
"github.com/goreleaser/goreleaser/internal/testlib"
|
||||||
|
|
||||||
"github.com/goreleaser/goreleaser/config"
|
|
||||||
|
|
||||||
"github.com/goreleaser/goreleaser/context"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,6 +20,12 @@ func TestChangelogProvidedViaFlag(t *testing.T) {
|
|||||||
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
|
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) {
|
func TestChangelog(t *testing.T) {
|
||||||
_, back := testlib.Mktmp(t)
|
_, back := testlib.Mktmp(t)
|
||||||
defer back()
|
defer back()
|
||||||
@@ -57,9 +62,18 @@ func TestChangelogOfFirstRelease(t *testing.T) {
|
|||||||
var ctx = context.New(config.Project{})
|
var ctx = context.New(config.Project{})
|
||||||
ctx.Git.CurrentTag = "v0.0.1"
|
ctx.Git.CurrentTag = "v0.0.1"
|
||||||
assert.NoError(t, Pipe{}.Run(ctx))
|
assert.NoError(t, Pipe{}.Run(ctx))
|
||||||
assert.Equal(t, "v0.0.1", ctx.Git.CurrentTag)
|
|
||||||
assert.Contains(t, ctx.ReleaseNotes, "## Changelog")
|
assert.Contains(t, ctx.ReleaseNotes, "## Changelog")
|
||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
assert.Contains(t, ctx.ReleaseNotes, msg)
|
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)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user