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:
parent
b84f6cdcb2
commit
809ef10fdd
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user