Reland: Update link branches to main (#146882)

Reland https://github.com/flutter/flutter/pull/146558, reverted in https://github.com/flutter/flutter/pull/146880 due to an outdated test result

## Original description

- Update CS and googlesource.com link branches
- Update GitHub /blob/ and /tree/ links

Tested links manually and fixes a few broken or deprecated links

Added a test that validates that `master` isn't used, except for specified repos.

Part of https://github.com/flutter/flutter/issues/121564
This commit is contained in:
Pierre-Louis
2024-04-17 15:16:33 +02:00
committed by GitHub
parent f5815f923a
commit 4a65a76279
42 changed files with 120 additions and 55 deletions

View File

@@ -61,7 +61,7 @@ actions through `recipe_modules`. Searching the builder config in [infra](https:
will indicate the recipe used for a test.
Recipes are just Python with some limitations on what can be imported. They are
[documented](https://github.com/luci/recipes-py/blob/master/doc/user_guide.md)
[documented](https://github.com/luci/recipes-py/blob/main/doc/user_guide.md)
by the [luci/recipes-py GitHub project](https://github.com/luci/recipes-py).
The typical cycle for editing a recipe is:

View File

@@ -109,9 +109,12 @@ Future<void> run(List<String> arguments) async {
printProgress('Debug mode instead of checked mode...');
await verifyNoCheckedMode(flutterRoot);
printProgress('Links for creating GitHub issues');
printProgress('Links for creating GitHub issues...');
await verifyIssueLinks(flutterRoot);
printProgress('Links to repositories...');
await verifyRepositoryLinks(flutterRoot);
printProgress('Unexpected binaries...');
await verifyNoBinaries(flutterRoot);
@@ -471,7 +474,7 @@ Future<void> verifyMaterialFilesAreUpToDateWithTemplateFiles(String workingDirec
if (errors.isNotEmpty) {
foundError(<String>[
...errors,
'${bold}See: https://github.com/flutter/flutter/blob/master/dev/tools/gen_defaults to update the token template files.$reset',
'${bold}See: https://github.com/flutter/flutter/blob/main/dev/tools/gen_defaults to update the token template files.$reset',
]);
}
}
@@ -1220,7 +1223,7 @@ String _bullets(String value) => ' * $value';
Future<void> verifyIssueLinks(String workingDirectory) async {
const String issueLinkPrefix = 'https://github.com/flutter/flutter/issues/new';
const Set<String> stops = <String>{ '\n', ' ', "'", '"', r'\', ')', '>' };
assert(!stops.contains('.')); // instead of "visit https://foo." say "visit: https://", it copy-pastes better
assert(!stops.contains('.')); // instead of "visit https://foo." say "visit: https://foo", it copy-pastes better
const String kGiveTemplates =
'Prefer to provide a link either to $issueLinkPrefix/choose (the list of issue '
'templates) or to a specific template directly ($issueLinkPrefix?template=...).\n';
@@ -1291,6 +1294,68 @@ Future<void> verifyIssueLinks(String workingDirectory) async {
}
}
Future<void> verifyRepositoryLinks(String workingDirectory) async {
const Set<String> stops = <String>{ '\n', ' ', "'", '"', r'\', ')', '>' };
assert(!stops.contains('.')); // instead of "visit https://foo." say "visit: https://foo", it copy-pastes better
// Repos whose default branch is still 'master'
const Set<String> repoExceptions = <String>{
'clojure/clojure',
'dart-lang/test', // TODO(guidezpl): remove when https://github.com/dart-lang/test/issues/2209 is closed
'eseidelGoogle/bezier_perf',
'flutter/devtools', // TODO(guidezpl): remove when https://github.com/flutter/devtools/issues/7551 is closed
'flutter/flutter_gallery_assets', // TODO(guidezpl): remove when subtask in https://github.com/flutter/flutter/issues/121564 is complete
'flutter/flutter-intellij', // TODO(guidezpl): remove when https://github.com/flutter/flutter-intellij/issues/7342 is closed
'flutter/platform_tests', // TODO(guidezpl): remove when subtask in https://github.com/flutter/flutter/issues/121564 is complete
'glfw/glfw',
'material-components/material-components-android', // TODO(guidezpl): remove when https://github.com/material-components/material-components-android/issues/4144 is closed
'torvalds/linux',
'tpn/winsdk-10',
};
const List<String> linkPrefixes = <String>[
'https://raw.githubusercontent.com/',
'https://github.com/',
];
final List<String> problems = <String>[];
final Set<String> suggestions = <String>{};
final List<File> files = await _gitFiles(workingDirectory);
for (final File file in files) {
for (final String linkPrefix in linkPrefixes) {
final Uint8List bytes = file.readAsBytesSync();
// We allow invalid UTF-8 here so that binaries don't trip us up.
// There's a separate test in this file that verifies that all text
// files are actually valid UTF-8 (see verifyNoBinaries below).
final String contents = utf8.decode(bytes, allowMalformed: true);
int start = 0;
while ((start = contents.indexOf(linkPrefix, start)) >= 0) {
int end = start + linkPrefixes.length;
while (end < contents.length && !stops.contains(contents[end])) {
end += 1;
}
final String url = contents.substring(start, end);
if (url.startsWith(linkPrefix) && !repoExceptions.any(url.contains)) {
if (url.contains('master')) {
problems.add('${file.path} contains $url, which uses the banned "master" branch.');
suggestions.add('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.');
}
}
start = end;
}
}
}
assert(problems.isEmpty == suggestions.isEmpty);
if (problems.isNotEmpty) {
foundError(<String>[
...problems,
...suggestions,
]);
}
}
@immutable
class Hash256 {
const Hash256(this.a, this.b, this.c, this.d);

View File

@@ -29,7 +29,7 @@ if [ ${PIPESTATUS[0]} -eq 0 ] || is_expected_failure "$log_file"; then
rm "$log_file"
else
all_builds_ok=0
echo "View https://github.com/flutter/flutter/blob/master/dev/bots/README.md for steps to resolve this failed build test." >> ${log_file}
echo "View https://github.com/flutter/flutter/blob/main/dev/bots/README.md for steps to resolve this failed build test." >> ${log_file}
echo
echo "Log left in $log_file."
echo

View File

@@ -310,7 +310,7 @@ void main() {
expect(result,
'╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════\n'
'$lines\n'
'║ See: https://github.com/flutter/flutter/blob/master/dev/tools/gen_defaults to update the token template files.\n'
'║ See: https://github.com/flutter/flutter/blob/main/dev/tools/gen_defaults to update the token template files.\n'
'╚═══════════════════════════════════════════════════════════════════════════════\n'
);
});

View File

@@ -13,7 +13,7 @@ import 'package:file/local.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
const String readmeUrl = 'https://github.com/flutter/flutter/tree/master/dev/conductor/README.md';
const String readmeUrl = 'https://github.com/flutter/flutter/tree/main/dev/conductor/README.md';
Future<void> main(List<String> args) async {
const FileSystem fileSystem = LocalFileSystem();

View File

@@ -60,7 +60,7 @@ Future<bool> run(List<String> arguments) async {
void printHelp() {
print('run_tests.dart [options...] path/to/file1.test path/to/file2.test...');
print('For details on the test registry format, see:');
print(' https://github.com/flutter/tests/blob/master/registry/template.test');
print(' https://github.com/flutter/tests/blob/main/registry/template.test');
print('');
print(argParser.usage);
print('');

View File

@@ -217,7 +217,7 @@ _TASK_- the name of your test that also matches the name of the
file in `bin/tasks` without the `.dart` extension.
1. Add target to
[.ci.yaml](https://github.com/flutter/flutter/blob/master/.ci.yaml)
[.ci.yaml](https://github.com/flutter/flutter/blob/main/.ci.yaml)
* Mirror an existing one that has the recipe `devicelab_drone`
If your test needs to run on multiple operating systems, create a separate
@@ -237,7 +237,7 @@ and the test will run based on the artifact against a testbed with a device.
Steps:
1. Update the task class to extend [`BuildTestTask`](https://github.com/flutter/flutter/blob/master/dev/devicelab/lib/tasks/build_test_task.dart)
1. Update the task class to extend [`BuildTestTask`](https://github.com/flutter/flutter/blob/main/dev/devicelab/lib/tasks/build_test_task.dart)
- Override function `getBuildArgs`
- Override function `getTestArgs`
- Override function `parseTaskResult`

View File

@@ -649,7 +649,7 @@ class AndroidDevice extends Device {
/// Retrieves device's wakefulness state.
///
/// See: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/PowerManagerInternal.java
/// See: https://android.googlesource.com/platform/frameworks/base/+/main/core/java/android/os/PowerManagerInternal.java
Future<String> _getWakefulness() async {
final String powerInfo = await shellEval('dumpsys', <String>['power']);
// A motoG4 phone returns `mWakefulness=Awake`.

View File

@@ -9,7 +9,7 @@
#
# In CI, this script currently depends on a modified version of bundletool because
# ddmlib which bundletool depends on does not yet support detecting QEMU emulator device
# density system properties. See https://android.googlesource.com/platform/tools/base/+/refs/heads/master/ddmlib/src/main/java/com/android/ddmlib/IDevice.java#46
# density system properties. See https://android.googlesource.com/platform/tools/base/+/refs/heads/main/ddmlib/src/main/java/com/android/ddmlib/IDevice.java#46
#
# The modified bundletool which waives the density requirement is at:
# https://chrome-infra-packages.appspot.com/p/flutter/android/bundletool/+/vFt1jA0cUeZLmUCVR5NG2JVB-SgJ18GH_pVYKMOlfUIC

View File

@@ -37,5 +37,5 @@ More resources:
[1]: https://chromedriver.chromium.org/downloads
[2]: https://flutter.dev/docs/development/tools/web-renderers
[3]: https://github.com/flutter/flutter/blob/master/dev/bots/test.dart
[3]: https://github.com/flutter/flutter/blob/main/dev/bots/test.dart
[4]: https://flutter.dev/docs/testing/build-modes

View File

@@ -4,4 +4,4 @@ The [snippets] tool uses the files in the `skeletons` directory to inject code
blocks generated from `{@tool dartpad}`, `{@tool sample}`, and `{@tool snippet}`
sections found in doc comments into the API docs.
[snippets]: https://github.com/flutter/assets-for-api-docs/tree/master/packages/snippets
[snippets]: https://github.com/flutter/assets-for-api-docs/tree/main/packages/snippets

View File

@@ -77,7 +77,7 @@ The planes are planned as follows:
- **Plane 0x01**: The unprintable plane. This plane contains logical keys that
are defined by the [Chromium key
list](https://chromium.googlesource.com/codesearch/chromium/src/+/refs/heads/master/ui/events/keycodes/dom/dom_key_data.inc)
list](https://chromium.googlesource.com/codesearch/chromium/src/+/refs/heads/main/ui/events/keycodes/dom/dom_key_data.inc)
and do not generate Unicode characters. The value is defined as the macro
value defined by the Chromium key list. Examples are CapsLock (0x105),
ArrowUp (0x304), F1 (0x801), Hiragata (0x716), and TVPower (0xD4B).

View File

@@ -39,7 +39,7 @@ Future<String> getChromiumKeys() async {
/// Get contents of the file that contains the key codes in Android source.
Future<String> getAndroidKeyCodes() async {
final Uri keyCodesUri = Uri.parse('https://android.googlesource.com/platform/frameworks/native/+/master/include/android/keycodes.h?format=TEXT');
final Uri keyCodesUri = Uri.parse('https://android.googlesource.com/platform/frameworks/native/+/main/include/android/keycodes.h?format=TEXT');
return utf8.decode(base64.decode(await http.read(keyCodesUri)));
}
@@ -55,7 +55,7 @@ Future<String> getWindowsKeyCodes() async {
/// common keyboards. Other than some special keyboards and game pads, this
/// should be OK.
Future<String> getAndroidScanCodes() async {
final Uri scanCodesUri = Uri.parse('https://android.googlesource.com/platform/frameworks/base/+/master/data/keyboards/Generic.kl?format=TEXT');
final Uri scanCodesUri = Uri.parse('https://android.googlesource.com/platform/frameworks/base/+/main/data/keyboards/Generic.kl?format=TEXT');
return utf8.decode(base64.decode(await http.read(scanCodesUri)));
}