[linter] Handle linter migration in generate_package_config.dart

The linter repository is moving into the SDK repo, moving
from third_party/pkg/linter to pkg/linter. Make generate_package_config.dart compatible with a non-breaking migration, that adds the package in the new location, changes Flutter and Dart
to use the new location, then removes the copy from the old location.

Bug: https://github.com/dart-lang/linter/issues/4411
Change-Id: I0653562a8af09a06582bbf17a44766fa64e2881f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321722
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
This commit is contained in:
William Hesse 2023-08-23 11:47:19 +00:00 committed by Commit Queue
parent 84ff6dd74e
commit 6e77184d71

View file

@ -82,7 +82,16 @@ void main(List<String> args) {
var hasDuplicatePackages = false;
for (var name in uniqueNames) {
var matches = packages.where((p) => p.name == name).toList();
var matches = [
for (final p in packages)
if (p.name == name) p
];
if (name == 'linter' && matches.length > 1) {
final oldLinter = matches
.firstWhere((p) => p.rootUri.endsWith('third_party/pkg/linter'));
packages.remove(oldLinter);
matches.remove(oldLinter);
}
if (matches.length > 1) {
print('Duplicates found for package:$name');
for (var package in matches) {