Skip to content

Commit 4deff2d

Browse files
authored
Update link branches to main (continued) (#146985)
I generalized the analysis to match all `googlesource.com` repos. I also added a test and fixed more cases. Part of flutter/flutter#121564 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
1 parent 12d54de commit 4deff2d

File tree

7 files changed

+62
-28
lines changed

7 files changed

+62
-28
lines changed

dev/bots/analyze.dart

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,38 +1316,36 @@ Future<void> verifyRepositoryLinks(String workingDirectory) async {
13161316
'tpn/winsdk-10',
13171317
};
13181318

1319-
const List<String> linkPrefixes = <String>[
1320-
'https://raw.githubusercontent.com/',
1321-
'https://github.com/',
1322-
];
1319+
// See dev/bots/test/analyze-test-input/root/packages/foo/bad_repository_links.dart
1320+
// for examples of repository links that are not allowed.
1321+
final RegExp pattern = RegExp(r'^(https:\/\/(?:cs\.opensource\.google|github|raw\.githubusercontent|source\.chromium|([a-z0-9\-]+)\.googlesource)\.)');
13231322

13241323
final List<String> problems = <String>[];
13251324
final Set<String> suggestions = <String>{};
1326-
final List<File> files = await _gitFiles(workingDirectory);
1325+
final List<File> files = await _allFiles(workingDirectory, null, minimumMatches: 10).toList();
13271326
for (final File file in files) {
1328-
for (final String linkPrefix in linkPrefixes) {
1329-
final Uint8List bytes = file.readAsBytesSync();
1330-
// We allow invalid UTF-8 here so that binaries don't trip us up.
1331-
// There's a separate test in this file that verifies that all text
1332-
// files are actually valid UTF-8 (see verifyNoBinaries below).
1333-
final String contents = utf8.decode(bytes, allowMalformed: true);
1334-
int start = 0;
1335-
while ((start = contents.indexOf(linkPrefix, start)) >= 0) {
1336-
int end = start + linkPrefixes.length;
1337-
while (end < contents.length && !stops.contains(contents[end])) {
1338-
end += 1;
1339-
}
1340-
final String url = contents.substring(start, end);
1341-
if (url.startsWith(linkPrefix) && !repoExceptions.any(url.contains)) {
1342-
if (url.contains('master')) {
1343-
problems.add('${file.path} contains $url, which uses the banned "master" branch.');
1344-
suggestions.add('Change the URLs above to the expected pattern by '
1327+
final Uint8List bytes = file.readAsBytesSync();
1328+
// We allow invalid UTF-8 here so that binaries don't trip us up.
1329+
// There's a separate test in this file that verifies that all text
1330+
// files are actually valid UTF-8 (see verifyNoBinaries below).
1331+
final String contents = utf8.decode(bytes, allowMalformed: true);
1332+
int start = 0;
1333+
while ((start = contents.indexOf('https://', start)) >= 0) { // Find all 'https://' links
1334+
int end = start + 8; // Length of 'https://'
1335+
while (end < contents.length && !stops.contains(contents[end])) {
1336+
end += 1;
1337+
}
1338+
final String url = contents.substring(start, end).replaceAll('\r', '');
1339+
1340+
if (pattern.hasMatch(url) && !repoExceptions.any(url.contains)) {
1341+
if (url.contains('master')) {
1342+
problems.add('${file.path} contains $url, which uses the banned "master" branch.');
1343+
suggestions.add('Change the URLs above to the expected pattern by '
13451344
'using the "main" branch if it exists, otherwise adding the '
13461345
'repository to the list of exceptions in analyze.dart.');
1347-
}
13481346
}
1349-
start = end;
13501347
}
1348+
start = end;
13511349
}
13521350
}
13531351
assert(problems.isEmpty == suggestions.isEmpty);

dev/bots/test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ Future<void> main(List<String> args) async {
143143
'framework_coverage': frameworkCoverageRunner,
144144
'framework_tests': _runFrameworkTests,
145145
'tool_tests': _runToolTests,
146-
// web_tool_tests is also used by HHH: https://dart.googlesource.com/recipes/+/refs/heads/master/recipes/dart/flutter_engine.py
147146
'web_tool_tests': _runWebToolTests,
148147
'tool_integration_tests': _runIntegrationToolTests,
149148
'android_preview_tool_integration_tests': _runAndroidPreviewIntegrationToolTests,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Check out https://android.googlesource.com/+/master/file1
6+
// Check out https://chromium.googlesource.com/+/master/file1
7+
// Check out https://cs.opensource.google.com/+/master/file1
8+
// Check out https://dart.googlesource.com/+/master/file1
9+
// Check out https://flutter.googlesource.com/+/master/file1
10+
// Check out https://source.chromium.org/+/master/file1
11+
// Check out https://github.com/flutter/flutter/tree/master/file1
12+
// Check out https://raw.githubusercontent.com/flutter/flutter/blob/master/file1

dev/bots/test/analyze_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ void main() {
147147
);
148148
});
149149

150+
test('analyze.dart - verifyRepositoryLinks', () async {
151+
final String result = await capture(() => verifyRepositoryLinks(testRootPath), shouldHaveErrors: true);
152+
const String bannedBranch = 'master';
153+
final String file = Platform.isWindows ?
154+
r'test\analyze-test-input\root\packages\foo\bad_repository_links.dart' :
155+
'test/analyze-test-input/root/packages/foo/bad_repository_links.dart';
156+
final String lines = <String>[
157+
'║ $file contains https://android.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
158+
'║ $file contains https://chromium.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
159+
'║ $file contains https://cs.opensource.google.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
160+
'║ $file contains https://dart.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
161+
'║ $file contains https://flutter.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
162+
'║ $file contains https://source.chromium.org/+/$bannedBranch/file1, which uses the banned "master" branch.',
163+
'║ $file contains https://github.com/flutter/flutter/tree/$bannedBranch/file1, which uses the banned "master" branch.',
164+
'║ $file contains https://raw.githubusercontent.com/flutter/flutter/blob/$bannedBranch/file1, which uses the banned "master" branch.',
165+
'║ Change the URLs above to the expected pattern by using the "main" branch if it exists, otherwise adding the repository to the list of exceptions in analyze.dart.',
166+
]
167+
.join('\n');
168+
expect(result,
169+
'╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════\n'
170+
'$lines\n'
171+
'╚═══════════════════════════════════════════════════════════════════════════════\n'
172+
);
173+
});
174+
150175
test('analyze.dart - verifyNoBinaries - positive', () async {
151176
final String result = await capture(() => verifyNoBinaries(
152177
testRootPath,

dev/customer_testing/ci.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ REM found in the LICENSE file.
66
REM This should match the ci.sh file in this directory.
77

88
REM This is called from the LUCI recipes:
9-
REM https://flutter.googlesource.com/recipes/+/refs/heads/master/recipe_modules/adhoc_validation/resources/customer_testing.bat
9+
REM https://github.com/flutter/flutter/blob/main/dev/bots/suite_runners/run_customer_testing_tests.dart
1010

1111
ECHO.
1212
ECHO Updating pub packages...

dev/customer_testing/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# This should match the ci.bat file in this directory.
77

88
# This is called from .cirrus.yml and the LUCI recipes:
9-
# https://flutter.googlesource.com/recipes/+/refs/heads/master/recipe_modules/adhoc_validation/resources/customer_testing.sh
9+
# https://github.com/flutter/flutter/blob/main/dev/bots/suite_runners/run_customer_testing_tests.dart
1010

1111
set -ex
1212

packages/flutter/lib/src/gestures/monodrag.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
669669
// it keeps track of the last accepted pointer. If this active pointer
670670
// leave up, it will be set to the first accepted pointer.
671671
// Refer to the implementation of Android `RecyclerView`(line 3846):
672-
// https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java
672+
// https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java
673673
int? _activePointer;
674674

675675
@override

0 commit comments

Comments
 (0)