Skip to content
Permalink
Browse files

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

  • Loading branch information...
caarlos0 committed Mar 3, 2019
1 parent b84f6cd commit 809ef10fdd2e4e80e3c6004d04e7342be1383699
Showing with 17 additions and 4 deletions.
  1. +6 −4 internal/pipe/changelog/changelog.go
  2. +11 −0 internal/pipe/changelog/changelog_test.go
@@ -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
}
@@ -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"

0 comments on commit 809ef10

Please sign in to comment.
You can’t perform that action at this time.