Skip to content

Commit a260bbe

Browse files
committed
update
1 parent 234100b commit a260bbe

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

script/tool/lib/src/branch_for_batch_release_command.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ class BranchForBatchReleaseCommand extends PackageCommand {
6565
final GitDir repository = await gitDir;
6666

6767
print('Parsing package "${package.displayName}"...');
68-
List<PendingChangelogEntry> pendingChangelogs = <PendingChangelogEntry>[];
68+
final List<PendingChangelogEntry> pendingChangelogs =
69+
<PendingChangelogEntry>[];
6970
try {
70-
pendingChangelogs = package.getPendingChangelogs();
71+
pendingChangelogs.addAll(package.getPendingChangelogs());
7172
} on FormatException catch (e) {
7273
printError('Failed to parse pending changelogs: ${e.message}');
7374
throw ToolExit(_kExitPackageMalformed);

script/tool/lib/src/common/repository_package.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ class RepositoryPackage {
125125
Pubspec parsePubspec() => _parsedPubspec;
126126

127127
late final CiConfig? _parsedCiConfig = ciConfigFile.existsSync()
128-
? CiConfig.parse(ciConfigFile.readAsStringSync())
128+
? CiConfig._parse(ciConfigFile.readAsStringSync())
129129
: null;
130130

131131
/// Returns the parsed [ciConfigFile], or null if it does not exist.
132-
///
133-
/// Caches for future use.
132+
///
133+
/// Throws if the file exists but is not a valid ci_config.yaml.
134134
CiConfig? parseCiConfig() => _parsedCiConfig;
135135

136136
/// Returns true if the package depends on Flutter.
@@ -238,8 +238,8 @@ class RepositoryPackage {
238238
/// This method reads through the files in the pending_changelogs folder
239239
/// and parses each file as a changelog entry.
240240
///
241-
/// Returns the parsed changelog entries for the package, and any errors
242-
/// that occurred trying to read them.
241+
/// Throws if the folder does not exist, or if any of the files are not
242+
/// valid changelog entries.
243243
List<PendingChangelogEntry> getPendingChangelogs() {
244244
final List<PendingChangelogEntry> entries = <PendingChangelogEntry>[];
245245

@@ -267,7 +267,8 @@ class RepositoryPackage {
267267

268268
for (final File file in pendingChangelogFiles) {
269269
try {
270-
entries.add(PendingChangelogEntry.parse(file.readAsStringSync(), file));
270+
entries
271+
.add(PendingChangelogEntry._parse(file.readAsStringSync(), file));
271272
} on FormatException catch (e) {
272273
throw FormatException(
273274
'Malformed pending changelog file: ${file.path}\n$e');
@@ -283,7 +284,9 @@ class CiConfig {
283284
CiConfig._(this.isBatchRelease);
284285

285286
/// Parses a [CiConfig] from a YAML string.
286-
factory CiConfig.parse(String yaml) {
287+
///
288+
/// Throws if the YAML is not a valid ci_config.yaml.
289+
factory CiConfig._parse(String yaml) {
287290
final Object? loaded = loadYaml(yaml);
288291
if (loaded is! YamlMap) {
289292
throw const FormatException('Root of ci_config.yaml must be a map.');
@@ -369,7 +372,9 @@ class PendingChangelogEntry {
369372
{required this.changelog, required this.version, required this.file});
370373

371374
/// Creates a PendingChangelogEntry from a YAML string.
372-
factory PendingChangelogEntry.parse(String yamlContent, File file) {
375+
///
376+
/// Throws if the YAML is not a valid pending changelog entry.
377+
factory PendingChangelogEntry._parse(String yamlContent, File file) {
373378
final dynamic yaml = loadYaml(yamlContent);
374379
if (yaml is! YamlMap) {
375380
throw FormatException(
@@ -406,5 +411,3 @@ class PendingChangelogEntry {
406411
/// The file that this entry was parsed from.
407412
final File file;
408413
}
409-
410-

0 commit comments

Comments
 (0)