mirror of
https://github.com/dart-lang/sdk
synced 2024-07-20 18:05:01 +00:00
[ Presubmit ] Only update .dart_tool/package_config.json when package
contents don't match Should reduce the frequency of trivial merge conflicts due to differing times of the "generated" property. Change-Id: I1f481d48be0aa21c923c63aedb7d9888d8618bcc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207503 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
9cf61baf57
commit
ba50910764
|
@ -92,22 +92,20 @@ void main(List<String> args) {
|
|||
packages.sort((a, b) => a["name"].compareTo(b["name"]));
|
||||
|
||||
var configFile = File(p.join(repoRoot, '.dart_tool', 'package_config.json'));
|
||||
var json =
|
||||
jsonDecode(configFile.readAsStringSync()) as Map<dynamic, dynamic>;
|
||||
var oldPackages = json['packages'] as List<dynamic>;
|
||||
|
||||
// Validate the packages entry only, to avoid spurious failures from changes
|
||||
// in the dates embedded in the other entries.
|
||||
if (checkOnly) {
|
||||
var json =
|
||||
jsonDecode(configFile.readAsStringSync()) as Map<dynamic, dynamic>;
|
||||
var oldPackages = json['packages'] as List<dynamic>;
|
||||
if (jsonEncode(packages) == jsonEncode(oldPackages)) {
|
||||
print("Package config up to date");
|
||||
exit(0);
|
||||
} else {
|
||||
print("Package config out of date");
|
||||
print("Run `gclient sync -D && dart tools/generate_package_config.dart` "
|
||||
"to update.");
|
||||
exit(1);
|
||||
}
|
||||
if (jsonEncode(packages) == jsonEncode(oldPackages)) {
|
||||
print("Package config up to date");
|
||||
exit(0);
|
||||
} else if (checkOnly) {
|
||||
print("Package config out of date");
|
||||
print("Run `gclient sync -D && dart tools/generate_package_config.dart` "
|
||||
"to update.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
var year = DateTime.now().year;
|
||||
|
@ -130,8 +128,8 @@ void main(List<String> args) {
|
|||
};
|
||||
|
||||
// TODO(rnystrom): Consider using package_config_v2 to generate this instead.
|
||||
var json = JsonEncoder.withIndent(' ').convert(config);
|
||||
configFile.writeAsStringSync('$json\n');
|
||||
var jsonString = JsonEncoder.withIndent(' ').convert(config);
|
||||
configFile.writeAsStringSync('$jsonString\n');
|
||||
print('Generated .dart_tool/package_config.dart containing '
|
||||
'${packages.length} packages.');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue