Skip to content

Commit 77f0ed1

Browse files
DanTupCommit Queue
authored andcommitted
Handle Windows newlines in tools/VERSION when generating package_config
Fixes #60497 which was caused by the parsed values for version numbers having trailing `\r`s. Change-Id: Icf40727c540c2c5dfea1c18cc91a00acf81ba6b4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421222 Commit-Queue: Alexander Thomas <[email protected]> Reviewed-by: Alexander Thomas <[email protected]> Reviewed-by: Ivan Inozemtsev <[email protected]>
1 parent 7a44485 commit 77f0ed1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tools/generate_package_config.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,11 @@ $overrides
102102
String currentSDKVersion() {
103103
final versionContents =
104104
File.fromUri(repoRoot.resolve('tools/VERSION')).readAsStringSync();
105-
final lines = versionContents
106-
.split('\n')
107-
.where((line) => !line.startsWith('#') && line.isNotEmpty);
108-
final versionParts = Map.fromEntries(lines.map((line) {
109-
final parts = line.split(' ');
110-
return MapEntry(parts[0], parts[1]);
111-
}));
105+
final lines = LineSplitter.split(versionContents);
106+
final versionParts = {
107+
for (var line in lines)
108+
if (line.isNotEmpty && !line.startsWith('#'))
109+
if (line.split(' ') case [final key, final value]) key: value
110+
};
112111
return '${versionParts['MAJOR']}.${versionParts['MINOR']}.${versionParts['PATCH']}';
113112
}

0 commit comments

Comments
 (0)