Skip to content

Commit

Permalink
Allow prerelease suffix in CHANGELOG versions (#112)
Browse files Browse the repository at this point in the history
Expand the regex to allow trailing suffixes like `-wip`. Add a test with
a `-wip` version.
  • Loading branch information
natebosch authored Jun 13, 2023
1 parent a2dac18 commit b1056e6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.17

- Correctly parse pre-release versions from the CHANGELOG.

## 0.3.16

- More robust version checking, now more diverse changelog formats are accepted.
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/lib/src/changelog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Changelog {
return null;
}

final versionRegex = RegExp(r'[0-9]+\.[0-9]+\.[0-9]+(\+[0-9]+)?');
final versionRegex = RegExp(r'[0-9]+\.[0-9]+\.[0-9]+([-\+]\w+)?');

var match = versionRegex.firstMatch(input);

Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.3.16
version: 0.3.17
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down
10 changes: 10 additions & 0 deletions pkgs/firehose/test/changelog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ void main() {
});
});

test('with prerelease tag', () {
withChangelog('''
## 123.456.789-wip
''', (file) {
var changelog = Changelog(file);
var version = changelog.latestVersion;
expect(version, '123.456.789-wip');
});
});

test('custom heading version', () {
withChangelog('''
## [4.7.0](https://github.com/...) (2023-05-06)
Expand Down

0 comments on commit b1056e6

Please sign in to comment.