@@ -428,6 +428,11 @@ void main() {
428
428
429
429
GitTagVersion .determine (processUtils, workingDirectory: '.' );
430
430
431
+ verifyNever (processUtils.runSync (
432
+ < String > ['git' , 'rev-parse' , '--abbrev-ref' , 'HEAD' ],
433
+ workingDirectory: anyNamed ('workingDirectory' ),
434
+ environment: anyNamed ('environment' ),
435
+ ));
431
436
verifyNever (processUtils.runSync (
432
437
< String > ['git' , 'fetch' , 'https://github.com/flutter/flutter.git' , '--tags' ],
433
438
workingDirectory: anyNamed ('workingDirectory' ),
@@ -440,21 +445,68 @@ void main() {
440
445
)).called (1 );
441
446
});
442
447
443
- testUsingContext ('determine calls fetch -- tags' , () {
448
+ testUsingContext ('determine does not fetch tags on dev/stable/beta ' , () {
444
449
final MockProcessUtils processUtils = MockProcessUtils ();
450
+ when (processUtils.runSync (
451
+ < String > ['git' , 'rev-parse' , '--abbrev-ref' , 'HEAD' ],
452
+ workingDirectory: anyNamed ('workingDirectory' ),
453
+ environment: anyNamed ('environment' ),
454
+ )).thenReturn (RunResult (ProcessResult (105 , 0 , 'dev' , '' ), < String > ['git' , 'fetch' ]));
445
455
when (processUtils.runSync (
446
456
< String > ['git' , 'fetch' , 'https://github.com/flutter/flutter.git' , '--tags' ],
447
457
workingDirectory: anyNamed ('workingDirectory' ),
448
458
environment: anyNamed ('environment' ),
449
- )).thenReturn (RunResult (ProcessResult (105 , 0 , '' , '' ), < String > ['git' , 'fetch' ]));
459
+ )).thenReturn (RunResult (ProcessResult (106 , 0 , '' , '' ), < String > ['git' , 'fetch' ]));
450
460
when (processUtils.runSync (
451
461
< String > ['git' , 'describe' , '--match' , 'v*.*.*' , '--first-parent' , '--long' , '--tags' ],
452
462
workingDirectory: anyNamed ('workingDirectory' ),
453
463
environment: anyNamed ('environment' ),
454
- )).thenReturn (RunResult (ProcessResult (106 , 0 , 'v0.1.2-3-1234abcd' , '' ), < String > ['git' , 'describe' ]));
464
+ )).thenReturn (RunResult (ProcessResult (107 , 0 , 'v0.1.2-3-1234abcd' , '' ), < String > ['git' , 'describe' ]));
465
+
466
+ GitTagVersion .determine (processUtils, workingDirectory: '.' , fetchTags: true );
467
+
468
+ verify (processUtils.runSync (
469
+ < String > ['git' , 'rev-parse' , '--abbrev-ref' , 'HEAD' ],
470
+ workingDirectory: anyNamed ('workingDirectory' ),
471
+ environment: anyNamed ('environment' ),
472
+ )).called (1 );
473
+ verifyNever (processUtils.runSync (
474
+ < String > ['git' , 'fetch' , 'https://github.com/flutter/flutter.git' , '--tags' ],
475
+ workingDirectory: anyNamed ('workingDirectory' ),
476
+ environment: anyNamed ('environment' ),
477
+ ));
478
+ verify (processUtils.runSync (
479
+ < String > ['git' , 'describe' , '--match' , 'v*.*.*' , '--first-parent' , '--long' , '--tags' ],
480
+ workingDirectory: anyNamed ('workingDirectory' ),
481
+ environment: anyNamed ('environment' ),
482
+ )).called (1 );
483
+ });
484
+
485
+ testUsingContext ('determine calls fetch --tags on master' , () {
486
+ final MockProcessUtils processUtils = MockProcessUtils ();
487
+ when (processUtils.runSync (
488
+ < String > ['git' , 'rev-parse' , '--abbrev-ref' , 'HEAD' ],
489
+ workingDirectory: anyNamed ('workingDirectory' ),
490
+ environment: anyNamed ('environment' ),
491
+ )).thenReturn (RunResult (ProcessResult (108 , 0 , 'master' , '' ), < String > ['git' , 'fetch' ]));
492
+ when (processUtils.runSync (
493
+ < String > ['git' , 'fetch' , 'https://github.com/flutter/flutter.git' , '--tags' ],
494
+ workingDirectory: anyNamed ('workingDirectory' ),
495
+ environment: anyNamed ('environment' ),
496
+ )).thenReturn (RunResult (ProcessResult (109 , 0 , '' , '' ), < String > ['git' , 'fetch' ]));
497
+ when (processUtils.runSync (
498
+ < String > ['git' , 'describe' , '--match' , 'v*.*.*' , '--first-parent' , '--long' , '--tags' ],
499
+ workingDirectory: anyNamed ('workingDirectory' ),
500
+ environment: anyNamed ('environment' ),
501
+ )).thenReturn (RunResult (ProcessResult (110 , 0 , 'v0.1.2-3-1234abcd' , '' ), < String > ['git' , 'describe' ]));
455
502
456
503
GitTagVersion .determine (processUtils, workingDirectory: '.' , fetchTags: true );
457
504
505
+ verify (processUtils.runSync (
506
+ < String > ['git' , 'rev-parse' , '--abbrev-ref' , 'HEAD' ],
507
+ workingDirectory: anyNamed ('workingDirectory' ),
508
+ environment: anyNamed ('environment' ),
509
+ )).called (1 );
458
510
verify (processUtils.runSync (
459
511
< String > ['git' , 'fetch' , 'https://github.com/flutter/flutter.git' , '--tags' ],
460
512
workingDirectory: anyNamed ('workingDirectory' ),
0 commit comments