1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00

fix: custom changelog and changelog.skip (#975)

This commit is contained in:
Carlos Alexandro Becker 2019-03-03 14:00:00 -03:00 committed by GitHub
parent b84f6cdcb2
commit 809ef10fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -28,9 +28,6 @@ func (Pipe) String() string {
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.Changelog.Skip {
return pipe.Skip("changelog should not be built")
}
// TODO: should probably have a different field for the filename and its
// contents.
if ctx.ReleaseNotes != "" {
@ -39,11 +36,16 @@ func (Pipe) Run(ctx *context.Context) error {
return err
}
ctx.ReleaseNotes = notes
return nil
}
if ctx.Config.Changelog.Skip {
return pipe.Skip("changelog should not be built")
}
if ctx.Snapshot {
return pipe.Skip("not available for snapshots")
}
if ctx.ReleaseNotes != "" {
return nil
}
if err := checkSortDirection(ctx.Config.Changelog.Sort); err != nil {
return err
}

View File

@ -23,6 +23,17 @@ func TestChangelogProvidedViaFlag(t *testing.T) {
require.Equal(t, "c0ff33 coffeee\n", ctx.ReleaseNotes)
}
func TestChangelogProvidedViaFlagAndSkipEnabled(t *testing.T) {
var ctx = context.New(config.Project{
Changelog: config.Changelog{
Skip: true,
},
})
ctx.ReleaseNotes = "testdata/changes.md"
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
require.Equal(t, "c0ff33 coffeee\n", ctx.ReleaseNotes)
}
func TestChangelogProvidedViaFlagDoesntExist(t *testing.T) {
var ctx = context.New(config.Project{})
ctx.ReleaseNotes = "testdata/changes.nope"