[flutter_tools] Make flutter git upstream configurable (#61513)
This commit is contained in:
parent
f9499f44f7
commit
7779a14794
@ -24,7 +24,7 @@ enum Channel {
|
||||
}
|
||||
|
||||
/// The flutter GitHub repository.
|
||||
const String _flutterGit = 'https://github.com/flutter/flutter.git';
|
||||
String get _flutterGit => globals.platform.environment['FLUTTER_GIT_URL'] ?? 'https://github.com/flutter/flutter.git';
|
||||
|
||||
/// Retrieve a human-readable name for a given [channel].
|
||||
///
|
||||
@ -259,6 +259,13 @@ class FlutterVersion {
|
||||
branch: '$_versionCheckRemote/$branch',
|
||||
lenient: false,
|
||||
);
|
||||
} on VersionCheckError catch (error) {
|
||||
if (globals.platform.environment.containsKey('FLUTTER_GIT_URL')) {
|
||||
globals.logger.printError('Warning: the Flutter git upstream was overriden '
|
||||
'by the environment variable FLUTTER_GIT_URL = $_flutterGit');
|
||||
}
|
||||
globals.logger.printError(error.toString());
|
||||
rethrow;
|
||||
} finally {
|
||||
await _removeVersionCheckRemoteIfExists();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import 'dart:convert';
|
||||
import 'package:collection/collection.dart' show ListEquality;
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/time.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
@ -609,6 +610,45 @@ void main() {
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
});
|
||||
|
||||
testUsingContext('determine uses overridden git url', () {
|
||||
final MockProcessUtils processUtils = MockProcessUtils();
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(108, 0, 'master', ''), <String>['git', 'fetch']));
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'fetch', 'https://githubmirror.com/flutter.git', '--tags', '-f'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(109, 0, '', ''), <String>['git', 'fetch']));
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'tag', '--contains', 'HEAD'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(
|
||||
RunResult(ProcessResult(110, 0, '', ''),
|
||||
<String>['git', 'tag', '--contains', 'HEAD'],
|
||||
));
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(111, 0, 'v0.1.2-3-1234abcd', ''), <String>['git', 'describe']));
|
||||
|
||||
GitTagVersion.determine(processUtils, workingDirectory: '.', fetchTags: true);
|
||||
|
||||
verify(processUtils.runSync(
|
||||
<String>['git', 'fetch', 'https://githubmirror.com/flutter.git', '--tags', '-f'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => FakePlatform(environment: <String, String>{
|
||||
'FLUTTER_GIT_URL': 'https://githubmirror.com/flutter.git',
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
void _expectVersionMessage(String message) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user