Skip to content

Commit

Permalink
Merge pull request #128 from leviathan747/empty-unreleased-subsections
Browse files Browse the repository at this point in the history
allow unreleased CHANGELOG section if all subsections are empty
  • Loading branch information
jgravois authored May 18, 2021
2 parents 260fedd + 20b9a8e commit 187911d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Unreleased]

### Changed
- Allow unreleased CHANGELOG section if all subsections are empty

## [5.0.0](https://github.com/hypermodules/gh-release/compare/v4.0.5-beta.0...v5.0.0) - 2021-01-16

- A release of 4.0.5-beta.0 as a breaking change
Expand Down
2 changes: 1 addition & 1 deletion bin/lib/get-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function getDefaults (workPath, isEnterprise, callback) {
? release.title.toLowerCase().indexOf('unreleased') !== -1
: false
}).filter(function (release) {
return !!release.body
return Object.values(release.parsed).flat().length > 0
})

if (unreleased.length > 0) {
Expand Down
17 changes: 17 additions & 0 deletions test/fixtures/unreleased-empty-subsections/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## [Unreleased]

### Added

### Changed

### Removed

### Deprecated

### Fixed

### Security


## 1.0.0
- bananas
8 changes: 8 additions & 0 deletions test/fixtures/unreleased-empty-subsections/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "gh-release-test",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "https://github.com/bcomnes/gh-release-test.git"
}
}
9 changes: 9 additions & 0 deletions test/get-defaults-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ test('get-defaults supports package.json with an enterprise repo', function (t)
})
})

test('get-defaults allows CHANGELOGs with empty fixtures', function (t) {
t.plan(3)
getDefaults(path.join(__dirname, 'fixtures/unreleased-empty-subsections'), true, function (err, defaults) {
t.equal(err, null, 'error should be null')
t.equal(defaults.owner, 'bcomnes', 'gets owner from package.json')
t.equal(defaults.repo, 'gh-release-test', 'gets repo from package.json')
})
})

test('get-defaults errors out with an invalid repository URL', function (t) {
t.plan(1)
getDefaults(path.join(__dirname, 'fixtures/invalid-repo'), false, function (err, defaults) {
Expand Down
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ test('should allow empty unreleased sections', function (t) {
t.notEqual(err.message, errStr)
})
})

test('should allow empty unreleased sub-sections', function (t) {
const errStr = 'Unreleased changes detected in CHANGELOG.md, aborting'
t.plan(1)
ghRelease({
workpath: fixture('unreleased-empty-subsections')
}, function (err, result) {
t.notEqual(err.message, errStr)
})
})

0 comments on commit 187911d

Please sign in to comment.