Only fetch tags when not on dev/beta/stable (#53450)
This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user