mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
Only fetch tags when not on dev/beta/stable (#53450)
This commit is contained in:
parent
dfc3318e87
commit
c8efcb632b
|
@ -722,7 +722,12 @@ class GitTagVersion {
|
|||
|
||||
static GitTagVersion determine(ProcessUtils processUtils, {String workingDirectory, bool fetchTags = false}) {
|
||||
if (fetchTags) {
|
||||
_runGit('git fetch $_flutterGit --tags', processUtils, workingDirectory);
|
||||
final String channel = _runGit('git rev-parse --abbrev-ref HEAD', processUtils, workingDirectory);
|
||||
if (channel == 'dev' || channel == 'beta' || channel == 'stable') {
|
||||
globals.printTrace('Skipping request to fetchTags - on well known channel $channel.');
|
||||
} else {
|
||||
_runGit('git fetch $_flutterGit --tags', processUtils, workingDirectory);
|
||||
}
|
||||
}
|
||||
return parse(_runGit('git describe --match v*.*.* --first-parent --long --tags', processUtils, workingDirectory));
|
||||
}
|
||||
|
|
|
@ -428,6 +428,11 @@ void main() {
|
|||
|
||||
GitTagVersion.determine(processUtils, workingDirectory: '.');
|
||||
|
||||
verifyNever(processUtils.runSync(
|
||||
<String>['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
));
|
||||
verifyNever(processUtils.runSync(
|
||||
<String>['git', 'fetch', 'https://github.com/flutter/flutter.git', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
|
@ -440,21 +445,68 @@ void main() {
|
|||
)).called(1);
|
||||
});
|
||||
|
||||
testUsingContext('determine calls fetch --tags', () {
|
||||
testUsingContext('determine does not fetch tags on dev/stable/beta', () {
|
||||
final MockProcessUtils processUtils = MockProcessUtils();
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(105, 0, 'dev', ''), <String>['git', 'fetch']));
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'fetch', 'https://github.com/flutter/flutter.git', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(105, 0, '', ''), <String>['git', 'fetch']));
|
||||
)).thenReturn(RunResult(ProcessResult(106, 0, '', ''), <String>['git', 'fetch']));
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'describe', '--match', 'v*.*.*', '--first-parent', '--long', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(106, 0, 'v0.1.2-3-1234abcd', ''), <String>['git', 'describe']));
|
||||
)).thenReturn(RunResult(ProcessResult(107, 0, 'v0.1.2-3-1234abcd', ''), <String>['git', 'describe']));
|
||||
|
||||
GitTagVersion.determine(processUtils, workingDirectory: '.', fetchTags: true);
|
||||
|
||||
verify(processUtils.runSync(
|
||||
<String>['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
verifyNever(processUtils.runSync(
|
||||
<String>['git', 'fetch', 'https://github.com/flutter/flutter.git', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
));
|
||||
verify(processUtils.runSync(
|
||||
<String>['git', 'describe', '--match', 'v*.*.*', '--first-parent', '--long', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
});
|
||||
|
||||
testUsingContext('determine calls fetch --tags on master', () {
|
||||
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://github.com/flutter/flutter.git', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(109, 0, '', ''), <String>['git', 'fetch']));
|
||||
when(processUtils.runSync(
|
||||
<String>['git', 'describe', '--match', 'v*.*.*', '--first-parent', '--long', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(RunResult(ProcessResult(110, 0, 'v0.1.2-3-1234abcd', ''), <String>['git', 'describe']));
|
||||
|
||||
GitTagVersion.determine(processUtils, workingDirectory: '.', fetchTags: true);
|
||||
|
||||
verify(processUtils.runSync(
|
||||
<String>['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
verify(processUtils.runSync(
|
||||
<String>['git', 'fetch', 'https://github.com/flutter/flutter.git', '--tags'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
|
|
Loading…
Reference in a new issue