Skip to content

Commit

Permalink
fix: extend release notes regex to support patches (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed May 20, 2019
1 parent 2c3e962 commit e887626
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
14 changes: 14 additions & 0 deletions __snapshots__/github-release.js
@@ -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
4 changes: 3 additions & 1 deletion src/github-release.ts
Expand Up @@ -80,7 +80,9 @@ 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
@@ -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
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);
});
});
});

0 comments on commit e887626

Please sign in to comment.