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 https://github.com/flutter/flutter/issues/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
This commit is contained in:
Pierre-Louis
2024-04-19 10:46:24 +02:00
committed by GitHub
parent 12d54de962
commit 4deff2dd9c
7 changed files with 62 additions and 28 deletions

View File

@@ -0,0 +1,12 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Check out https://android.googlesource.com/+/master/file1
// Check out https://chromium.googlesource.com/+/master/file1
// Check out https://cs.opensource.google.com/+/master/file1
// Check out https://dart.googlesource.com/+/master/file1
// Check out https://flutter.googlesource.com/+/master/file1
// Check out https://source.chromium.org/+/master/file1
// Check out https://github.com/flutter/flutter/tree/master/file1
// Check out https://raw.githubusercontent.com/flutter/flutter/blob/master/file1

View File

@@ -147,6 +147,31 @@ void main() {
);
});
test('analyze.dart - verifyRepositoryLinks', () async {
final String result = await capture(() => verifyRepositoryLinks(testRootPath), shouldHaveErrors: true);
const String bannedBranch = 'master';
final String file = Platform.isWindows ?
r'test\analyze-test-input\root\packages\foo\bad_repository_links.dart' :
'test/analyze-test-input/root/packages/foo/bad_repository_links.dart';
final String lines = <String>[
'║ $file contains https://android.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
'║ $file contains https://chromium.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
'║ $file contains https://cs.opensource.google.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
'║ $file contains https://dart.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
'║ $file contains https://flutter.googlesource.com/+/$bannedBranch/file1, which uses the banned "master" branch.',
'║ $file contains https://source.chromium.org/+/$bannedBranch/file1, which uses the banned "master" branch.',
'║ $file contains https://github.com/flutter/flutter/tree/$bannedBranch/file1, which uses the banned "master" branch.',
'║ $file contains https://raw.githubusercontent.com/flutter/flutter/blob/$bannedBranch/file1, which uses the banned "master" branch.',
'║ 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.',
]
.join('\n');
expect(result,
'╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════\n'
'$lines\n'
'╚═══════════════════════════════════════════════════════════════════════════════\n'
);
});
test('analyze.dart - verifyNoBinaries - positive', () async {
final String result = await capture(() => verifyNoBinaries(
testRootPath,