issue, too
diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index b6dd6cc..1ebaa19 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart
@@ -50,9 +50,18 @@ 'GITHUB_REPOSITORY environment variable is not set.', )); + late final int? _resolvedIssueNumber = _issueNumber ?? + (switch (_env['ISSUE_NUMBER']) { + final s? => int.tryParse(s), + _ => null, + }); + /// The PR (or issue) number. - int? get issueNumber => - _issueNumber ?? int.tryParse(_env['ISSUE_NUMBER'] ?? ''); + int? get issueNumber => _resolvedIssueNumber; + + int get _issue => + _resolvedIssueNumber ?? + (throw StateError('ISSUE_NUMBER environment variable is not set.')); /// Any labels applied to this PR. List<String> get prLabels => @@ -101,7 +110,7 @@ String? searchTerm, }) async { final matchingComment = await _github.issues - .listCommentsByIssue(_slug, issueNumber!) + .listCommentsByIssue(_slug, _issue) .map<IssueComment?>((comment) => comment) .firstWhere( (comment) { @@ -128,7 +137,7 @@ List<Glob> ignoredFiles = const [], ]) async => await _github.pullRequests - .listFiles(_slug, issueNumber!) + .listFiles(_slug, _issue) .map((prFile) => GitFile( prFile.filename!, FileStatus.fromString(prFile.status!), @@ -170,7 +179,7 @@ } Future<String> pullrequestBody() async { - final pullRequest = await _github.pullRequests.get(_slug, issueNumber!); + final pullRequest = await _github.pullRequests.get(_slug, _issue); return pullRequest.body ?? ''; }