Unverified Commit ce3c3d2a authored by Anurag Roy's avatar Anurag Roy Committed by GitHub

[flutter_tools] Show upstream remote in `flutter doctor -v` (#80101)

parent 257f5112
......@@ -20,6 +20,8 @@ class UserMessages {
'Flutter version $version at $flutterRoot';
String flutterRevision(String revision, String age, String date) =>
'Framework revision $revision ($age), $date';
String flutterUpstreamRepositoryUrl(String url) => 'Upstream repository $url';
String flutterGitUrl(String url) => 'FLUTTER_GIT_URL = $url';
String engineRevision(String revision) => 'Engine revision $revision';
String dartRevision(String revision) => 'Dart version $revision';
String pubMirrorURL(String url) => 'Pub download mirror $url';
......
......@@ -436,6 +436,10 @@ class FlutterValidator extends DoctorValidator {
frameworkVersion,
_flutterRoot(),
)));
messages.add(ValidationMessage(_userMessages.flutterUpstreamRepositoryUrl(version.repositoryUrl ?? 'unknown')));
if (_platform.environment.containsKey('FLUTTER_GIT_URL')) {
messages.add(ValidationMessage(_userMessages.flutterGitUrl(_platform.environment['FLUTTER_GIT_URL'])));
}
messages.add(ValidationMessage(_userMessages.flutterRevision(
version.frameworkRevisionShort,
version.frameworkAge,
......
......@@ -118,11 +118,11 @@ void main() {
expect(await flutterValidator.validate(), _matchDoctorValidation(
validationType: ValidationType.partial,
statusInfo: 'Channel unknown, 0.0.0, on Windows, locale en_US.UTF-8',
messages: const <ValidationMessage>[
messages: containsAll(const <ValidationMessage>[
ValidationMessage('Flutter version 0.0.0 at sdk/flutter'),
ValidationMessage.error('version error'),
]),
);
));
});
testWithoutContext('FlutterValidator shows mirrors on pub and flutter cloud storage', () async {
......@@ -159,6 +159,73 @@ void main() {
])
));
});
testWithoutContext('FlutterValidator shows FLUTTER_GIT_URL environment variable when set', () async {
final FlutterValidator flutterValidator = FlutterValidator(
platform: FakePlatform(
localeName: 'en_US.UTF-8',
environment: <String, String> {
'FLUTTER_GIT_URL': 'https://githubmirror.com/flutter.git',
},
),
flutterVersion: () => FakeFlutterVersion(frameworkVersion: '1.0.0'),
userMessages: UserMessages(),
artifacts: Artifacts.test(),
fileSystem: MemoryFileSystem.test(),
processManager: FakeProcessManager.any(),
operatingSystemUtils: FakeOperatingSystemUtils(name: 'Linux'),
flutterRoot: () => 'sdk/flutter',
);
expect(await flutterValidator.validate(), _matchDoctorValidation(
validationType: ValidationType.installed,
statusInfo: 'Channel unknown, 1.0.0, on Linux, locale en_US.UTF-8',
messages: contains(const ValidationMessage('FLUTTER_GIT_URL = https://githubmirror.com/flutter.git')),
));
});
group('FlutterValidator shows flutter upstream remote', () {
testWithoutContext('default url', () async {
final FlutterValidator flutterValidator = FlutterValidator(
platform: FakePlatform(localeName: 'en_US.UTF-8'),
flutterVersion: () => FakeFlutterVersion(frameworkVersion: '1.0.0'),
userMessages: UserMessages(),
artifacts: Artifacts.test(),
fileSystem: MemoryFileSystem.test(),
processManager: FakeProcessManager.any(),
operatingSystemUtils: FakeOperatingSystemUtils(name: 'Linux'),
flutterRoot: () => 'sdk/flutter',
);
expect(await flutterValidator.validate(), _matchDoctorValidation(
validationType: ValidationType.installed,
statusInfo: 'Channel unknown, 1.0.0, on Linux, locale en_US.UTF-8',
messages: contains(const ValidationMessage('Upstream repository https://github.com/flutter/flutter.git')),
));
});
testWithoutContext('unknown url if upstream is null', () async {
final FlutterValidator flutterValidator = FlutterValidator(
platform: FakePlatform(localeName: 'en_US.UTF-8'),
flutterVersion: () => FakeFlutterVersion(
frameworkVersion: '1.0.0',
repositoryUrl: null,
),
userMessages: UserMessages(),
artifacts: Artifacts.test(),
fileSystem: MemoryFileSystem.test(),
processManager: FakeProcessManager.any(),
operatingSystemUtils: FakeOperatingSystemUtils(name: 'Linux'),
flutterRoot: () => 'sdk/flutter',
);
expect(await flutterValidator.validate(), _matchDoctorValidation(
validationType: ValidationType.installed,
statusInfo: 'Channel unknown, 1.0.0, on Linux, locale en_US.UTF-8',
messages: contains(const ValidationMessage('Upstream repository unknown')),
));
});
});
}
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment