diff --git a/bin/lib/get-defaults.js b/bin/lib/get-defaults.js index 3e91470..de1251a 100644 --- a/bin/lib/get-defaults.js +++ b/bin/lib/get-defaults.js @@ -19,10 +19,14 @@ function getDefaults (workPath, callback) { changelogParser(logPath, function (err, result) { if (err) return callback(err) + // check for 'unreleased' section in CHANGELOG: allow sections which do not include a body (eg. 'Added', 'Changed', etc.) + var unreleased = result.versions.filter(function (release) { return release.title && release.title.toLowerCase ? release.title.toLowerCase().indexOf('unreleased') !== -1 : false + }).filter(function (release) { + return !!release.body }) if (unreleased.length > 0) { diff --git a/test/fixtures/unreleased/CHANGELOG.md b/test/fixtures/unreleased/CHANGELOG.md index 61e6ec2..3a0b963 100644 --- a/test/fixtures/unreleased/CHANGELOG.md +++ b/test/fixtures/unreleased/CHANGELOG.md @@ -1,4 +1,5 @@ ## Unreleased +- apples ## 1.0.0 - bananas diff --git a/test/index.js b/test/index.js index 61f90b7..8f3fea7 100644 --- a/test/index.js +++ b/test/index.js @@ -21,16 +21,22 @@ test('should return error if changelog version !== package.json version', functi }) }) -test('should return error if unreleased section exists', function (t) { - t.plan(2) +test('should return error if a non-empty unreleased section exists', function (t) { + var errStr = 'Unreleased changes detected in CHANGELOG.md, aborting' + t.plan(1) ghRelease({ workpath: fixture('unreleased') }, function (err, result) { - t.deepEqual(err.message, 'Unreleased changes detected in CHANGELOG.md, aborting') + t.deepEqual(err.message, errStr) }) +}) + +test('should allow empty unreleased sections', function (t) { + var errStr = 'Unreleased changes detected in CHANGELOG.md, aborting' + t.plan(1) ghRelease({ workpath: fixture('unreleased-alt') }, function (err, result) { - t.deepEqual(err.message, 'Unreleased changes detected in CHANGELOG.md, aborting') + t.notEqual(err.message, errStr) }) })