Skip to content

Excluded header when creating release blog post #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions scripts/release-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function download (url) {
// ## 2015-07-09, Version 0.12.7 (Stable)
// ## 2015-08-04, Version 3.0.0, @rvagg
const rxReleaseSection = /## \d{4}-\d{2}-\d{2}, Version ([^,( ]+)[\s\S]*?(?=## \d{4})/g
const rxSectionBody = /### Notable changes[\s\S]*/g

function explicitVersion (version) {
return version ? Promise.resolve(version) : Promise.reject()
Expand Down Expand Up @@ -94,9 +95,12 @@ function fetchChangelog (version) {

/* eslint-disable no-cond-assign */
while (matches = rxReleaseSection.exec(data)) {
const section = matches[0]
const releaseVersion = matches[1]
if (releaseVersion === version) {
return matches[0]
const bodyMatch = rxSectionBody.exec(section)

if (releaseVersion === version && bodyMatch) {
return bodyMatch[0]
}
}
/* eslint-enable no-cond-assign */
Expand Down
21 changes: 17 additions & 4 deletions tests/scripts/release-post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,35 @@ test('fetchChangelog(<version>)', (t) => {
t.true(github.isDone(), 'githubusercontent.com was requested')

t.end()
})
}, t.fail)
})

t.test('rejects when a matching version section could not be found in changelog', (t) => {
const github = nock('https://raw.githubusercontent.com')
.get('/nodejs/node/v4.1.1/CHANGELOG.md')
.get('/nodejs/node/v0.14.0/CHANGELOG.md')
.reply(200, 'A changelog without version sections...')

releasePost.fetchChangelog('4.1.1').then(null, (err) => {
t.equal(err.message, 'Couldnt find matching changelog for 4.1.1')
releasePost.fetchChangelog('0.14.0').then(t.fail, (err) => {
t.equal(err.message, 'Couldnt find matching changelog for 0.14.0')
t.true(github.isDone(), 'githubusercontent.com was requested')

t.end()
})
})

t.test('does not include `## header` in matched version section', (t) => {
const github = nock('https://raw.githubusercontent.com')
.get('/nodejs/node/v4.1.0/CHANGELOG.md')
.replyWithFile(200, changelogFixture)

releasePost.fetchChangelog('4.1.0').then((changelog) => {
t.true(changelog.startsWith('### Notable changes'))
t.true(github.isDone(), 'githubusercontent.com was requested')

t.end()
}, t.fail)
})

t.end()
})

Expand Down