Skip to content

Commit

Permalink
fix an NPE when we encounter a package without a changelog (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew authored Feb 1, 2023
1 parent feb73d6 commit bc7af81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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.10

- Fixed an exception that occurred when no CHANGELOG.md file was present.

## 0.3.9

- Update the 'publishable' PR comment to use a markdown table.
Expand Down
2 changes: 2 additions & 0 deletions pkgs/firehose/lib/src/changelog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Changelog {
}

Iterable<_Section> _parseSections() sync* {
if (!exists) return;

_Section? section;

for (var line in file.readAsLinesSync().where((line) => line.isNotEmpty)) {
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.9
version: 0.3.10
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

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

test('no changelog file', () {
var changelog = Changelog(File('missing_changelog.md'));
expect(changelog.exists, false);
expect(changelog.latestVersion, isNull);
expect(changelog.latestChangeEntries, isEmpty);
});

test('latestChangeEntries', () {
withChangelog(_defaultContents, (file) {
var changelog = Changelog(file);
Expand Down

0 comments on commit bc7af81

Please sign in to comment.