Skip to content
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

fix: extend release notes regex to support patches #142

Merged
merged 3 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions __snapshots__/github-release.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
exports['GitHubRelease extractLatestReleaseNotes extracts appropriate release notes when prior release is patch 1'] = `


### ⚠ BREAKING CHANGES

* temp directory now defaults to setting for report directory

### Features

* default temp directory to report directory ([#102](https://www.github.com/bcoe/c8/issues/102)) ([8602f4a](https://www.github.com/bcoe/c8/commit/8602f4a))
* load .nycrc/.nycrc.json to simplify migration ([#100](https://www.github.com/bcoe/c8/issues/100)) ([bd7484f](https://www.github.com/bcoe/c8/commit/bd7484f))

`

exports['GitHubRelease extractLatestReleaseNotes handles CHANGELOG with new format entries 1'] = `


Expand Down
2 changes: 1 addition & 1 deletion src/github-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class GitHubRelease {
string {
version = version.replace(/^v/, '');
const latestRe = new RegExp(
`## v?\\[?${version}[^\\n]*\\n(.*?)(\\n##\\s|($(?![\r\n])))`, 'ms');
`## v?\\[?${version}[^\\n]*\\n(.*?)(\\n##\\s|\\n### \\[?[0-9]\\.|($(?![\r\n])))`, 'ms');
const match = changelogContents.match(latestRe);
if (!match) {
throw Error('could not find changelog entry corresponding to release PR');
Expand Down
32 changes: 32 additions & 0 deletions test/fixtures/CHANGELOG-bug-140.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [5.0.0](https://www.github.com/bcoe/c8/compare/v4.1.5...v5.0.0) (2019-05-20)


### ⚠ BREAKING CHANGES

* temp directory now defaults to setting for report directory

### Features

* default temp directory to report directory ([#102](https://www.github.com/bcoe/c8/issues/102)) ([8602f4a](https://www.github.com/bcoe/c8/commit/8602f4a))
* load .nycrc/.nycrc.json to simplify migration ([#100](https://www.github.com/bcoe/c8/issues/100)) ([bd7484f](https://www.github.com/bcoe/c8/commit/bd7484f))

### [4.1.5](https://github.com/bcoe/c8/compare/v4.1.4...v4.1.5) (2019-05-11)


### Bug Fixes

* exit with code 1 when report output fails ([#92](https://github.com/bcoe/c8/issues/92)) ([a27b694](https://github.com/bcoe/c8/commit/a27b694))
* remove the unmaintained mkdirp dependency ([#91](https://github.com/bcoe/c8/issues/91)) ([a465b65](https://github.com/bcoe/c8/commit/a465b65))



## [4.1.4](https://github.com/bcoe/c8/compare/v4.1.3...v4.1.4) (2019-05-03)


### Bug Fixes

* we were not exiting with 1 if mkdir failed ([#89](https://github.com/bcoe/c8/issues/89)) ([fb02ed6](https://github.com/bcoe/c8/commit/fb02ed6))
10 changes: 10 additions & 0 deletions test/github-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,15 @@ describe('GitHubRelease', () => {
GitHubRelease.extractLatestReleaseNotes(changelogContent, 'v1.2.0');
snapshot(latestReleaseNotes);
});

// see: https://github.com/googleapis/release-please/issues/140
it('extracts appropriate release notes when prior release is patch', () => {
const changelogContent =
readFileSync(resolve(fixturesPath, './CHANGELOG-bug-140.md'), 'utf8')
.replace(/\r\n/g, '\n');
const latestReleaseNotes =
GitHubRelease.extractLatestReleaseNotes(changelogContent, 'v5.0.0');
snapshot(latestReleaseNotes);
});
});
});