diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index 1c35aa89..8d800845 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.32 + +- Fix an issue validating pre-release git publishing tags (#176). + ## 0.3.31 - Add PR Health checks for breaking changes. diff --git a/pkgs/firehose/lib/src/changelog.dart b/pkgs/firehose/lib/src/changelog.dart index 59b49651..9eb14621 100644 --- a/pkgs/firehose/lib/src/changelog.dart +++ b/pkgs/firehose/lib/src/changelog.dart @@ -26,19 +26,15 @@ class Changelog { /// Pattern recognizing some SemVer formats. /// /// Accepts: - /// > digits '.' digits '.' digits /// - /// optionally followed by `-` or `+` character - /// and one or more "word characters", which are - /// ASCII letters (`a`-`z`, `A`-`Z`), digits (`0`-`9`), - /// underscore (`_`) and dollar-sign (`$`). + /// > digits '.' digits '.' digits /// - /// This is not all complete SemVer version strings, - /// since it doesn't allow `.` in the continuation, - /// or a `+...` sequence after a `-` sequence. - /// It should be enough for the user-cases we need it for - /// in this package. - static final _versionRegex = RegExp(r'\d+\.\d+\.\d+(?:[\-+]\w+)?'); + /// optionally followed by `-` or `+` character and one of more non-whitespace + /// characters, without validating them as valid semver. + /// + /// This is not all complete SemVer version strings but it should be enough + /// for the user-cases we need it for in this package. + static final _versionRegex = RegExp(r'\d+\.\d+\.\d+(?:[+\-]\S*)?'); String? get latestVersion { var input = latestHeading; diff --git a/pkgs/firehose/lib/src/utils.dart b/pkgs/firehose/lib/src/utils.dart index cc68c3c1..90320836 100644 --- a/pkgs/firehose/lib/src/utils.dart +++ b/pkgs/firehose/lib/src/utils.dart @@ -44,25 +44,27 @@ Future runCommand( class Tag { /// RegExp matching a version tag at the start of a line. /// - /// A version tag is an optional starting seqeuence - /// of non-whitespace, which is the package name, - /// followed by a `v` and a simplified SemVer version + /// A version tag is an optional starting seqeuence of non-whitespace, which + /// is the package name, followed by a `v` and a simplified SemVer version /// number. - /// The version number accepted is + /// + /// The version number accepted is: + /// /// > digits '.' digits '.' digits /// - /// and if followed by a `+`, then it includes the - /// rest of the line. + /// and if followed by a `+` or `-`, then it includes the remaining + /// non-whitespace characters. static final RegExp packageVersionTag = - RegExp(r'^(?:(\S+)-)?v(\d+\.\d+\.\d+(?:\+.*)?)'); + RegExp(r'^(?:(\S+)-)?v(\d+\.\d+\.\d+(?:[+\-]\S*)?)'); /// A package version tag. /// /// Is expected to have the format: + /// /// > (package-name)? 'v' SemVer-version /// - /// If not, the tag is not [valid], and the [package] and [version] - /// will both be `null`. + /// If not, the tag is not [valid], and the [package] and [version] will both + /// be `null`. final String tag; Tag(this.tag); diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index a2caf145..04cde484 100644 --- a/pkgs/firehose/pubspec.yaml +++ b/pkgs/firehose/pubspec.yaml @@ -1,6 +1,6 @@ name: firehose description: A tool to automate publishing of Pub packages from GitHub actions. -version: 0.3.31 +version: 0.3.32 repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose environment: diff --git a/pkgs/firehose/test/changelog_test.dart b/pkgs/firehose/test/changelog_test.dart index d22020d9..ec1e72af 100644 --- a/pkgs/firehose/test/changelog_test.dart +++ b/pkgs/firehose/test/changelog_test.dart @@ -85,6 +85,16 @@ void main() { }); }); + test('with prerelease tag 2', () { + withChangelog(''' +## 123.456.789-beta.2 +''', (file) { + var changelog = Changelog(file); + var version = changelog.latestVersion; + expect(version, '123.456.789-beta.2'); + }); + }); + test('custom heading version', () { withChangelog(''' ## [4.7.0](https://github.com/...) (2023-05-06) diff --git a/pkgs/firehose/test/utils_test.dart b/pkgs/firehose/test/utils_test.dart index d7ad41b4..a253712e 100644 --- a/pkgs/firehose/test/utils_test.dart +++ b/pkgs/firehose/test/utils_test.dart @@ -22,6 +22,11 @@ void main() { expect(tag.version, '1.2.3'); }); + test('pre-release package repo', () { + var tag = Tag('v1.2.3-beta'); + expect(tag.version, '1.2.3-beta'); + }); + test('service release', () { var tag = Tag('v1.2.3+1'); expect(tag.version, '1.2.3+1'); @@ -39,6 +44,12 @@ void main() { expect(tag.version, '1.2.3'); }); + test('mono repo pre-release', () { + var tag = Tag('foo_bar-v1.2.3-dev.1'); + expect(tag.package, 'foo_bar'); + expect(tag.version, '1.2.3-dev.1'); + }); + test('mono repo bad', () { var tag = Tag('foobar_v1.2.3'); expect(tag.valid, false);