@@ -52,29 +52,19 @@ class PreparePackageException implements Exception {
52
52
}
53
53
}
54
54
55
- enum Branch { dev, beta, stable }
55
+ enum Branch {
56
+ beta,
57
+ stable;
56
58
57
- String getBranchName (Branch branch) {
58
- switch (branch) {
59
- case Branch .beta:
60
- return 'beta' ;
61
- case Branch .dev:
62
- return 'dev' ;
63
- case Branch .stable:
64
- return 'stable' ;
65
- }
66
- }
67
-
68
- Branch fromBranchName (String name) {
69
- switch (name) {
70
- case 'beta' :
71
- return Branch .beta;
72
- case 'dev' :
73
- return Branch .dev;
74
- case 'stable' :
75
- return Branch .stable;
76
- default :
77
- throw ArgumentError ('Invalid branch name.' );
59
+ static Branch fromName (String name) {
60
+ switch (name) {
61
+ case 'beta' :
62
+ return Branch .beta;
63
+ case 'stable' :
64
+ return Branch .stable;
65
+ default :
66
+ throw ArgumentError ('Invalid branch name.' );
67
+ }
78
68
}
79
69
}
80
70
@@ -304,9 +294,6 @@ class ArchiveCreator {
304
294
.trim ().split (' ' ).last.replaceAll ('"' , '' ).split ('_' )[1 ];
305
295
})();
306
296
307
- /// Get the name of the channel as a string.
308
- String get branchName => getBranchName (branch);
309
-
310
297
/// Returns a default archive name when given a Git revision.
311
298
/// Used when an output filename is not given.
312
299
Future <String > get _archiveName async {
@@ -321,7 +308,8 @@ class ArchiveCreator {
321
308
// unpacking it!) So, we use .zip for Mac, and the files are about
322
309
// 220MB larger than they need to be. :-(
323
310
final String suffix = platform.isLinux ? 'tar.xz' : 'zip' ;
324
- return 'flutter_${os }_$arch ${_version [frameworkVersionTag ]}-$branchName .$suffix ' ;
311
+ final String package = '${os }_$arch ${_version [frameworkVersionTag ]}' ;
312
+ return 'flutter_$package -${branch .name }.$suffix ' ;
325
313
}
326
314
327
315
/// Checks out the flutter repo and prepares it for other operations.
@@ -425,7 +413,7 @@ class ArchiveCreator {
425
413
// We want the user to start out the in the specified branch instead of a
426
414
// detached head. To do that, we need to make sure the branch points at the
427
415
// desired revision.
428
- await _runGit (< String > ['clone' , '-b' , branchName , gobMirror], workingDirectory: tempDir);
416
+ await _runGit (< String > ['clone' , '-b' , branch.name , gobMirror], workingDirectory: tempDir);
429
417
await _runGit (< String > ['reset' , '--hard' , revision]);
430
418
431
419
// Make the origin point to github instead of the chromium mirror.
@@ -624,8 +612,7 @@ class ArchivePublisher {
624
612
final File outputFile;
625
613
final ProcessRunner _processRunner;
626
614
final bool dryRun;
627
- String get branchName => getBranchName (branch);
628
- String get destinationArchivePath => '$branchName /$platformName /${path .basename (outputFile .path )}' ;
615
+ String get destinationArchivePath => '${branch .name }/$platformName /${path .basename (outputFile .path )}' ;
629
616
static String getMetadataFilename (Platform platform) => 'releases_${platform .operatingSystem .toLowerCase ()}.json' ;
630
617
631
618
Future <String > _getChecksum (File archiveFile) async {
@@ -666,14 +653,14 @@ class ArchivePublisher {
666
653
if (! jsonData.containsKey ('current_release' )) {
667
654
jsonData['current_release' ] = < String , String > {};
668
655
}
669
- (jsonData['current_release' ] as Map <String , dynamic >)[branchName ] = revision;
656
+ (jsonData['current_release' ] as Map <String , dynamic >)[branch.name ] = revision;
670
657
if (! jsonData.containsKey ('releases' )) {
671
658
jsonData['releases' ] = < Map <String , dynamic >> [];
672
659
}
673
660
674
661
final Map <String , dynamic > newEntry = < String , dynamic > {};
675
662
newEntry['hash' ] = revision;
676
- newEntry['channel' ] = branchName ;
663
+ newEntry['channel' ] = branch.name ;
677
664
newEntry['version' ] = version[frameworkVersionTag];
678
665
newEntry['dart_sdk_version' ] = version[dartVersionTag];
679
666
newEntry['dart_sdk_arch' ] = version[dartTargetArchTag];
@@ -825,7 +812,7 @@ Future<void> main(List<String> rawArguments) async {
825
812
'archive with. Must be the full 40-character hash. Required.' );
826
813
argParser.addOption (
827
814
'branch' ,
828
- allowed: Branch .values.map <String >((Branch branch) => getBranchName ( branch) ),
815
+ allowed: Branch .values.map <String >((Branch branch) => branch.name ),
829
816
help: 'The Flutter branch to build the archive with. Required.' ,
830
817
);
831
818
argParser.addOption (
@@ -907,7 +894,7 @@ Future<void> main(List<String> rawArguments) async {
907
894
908
895
final bool publish = parsedArguments['publish' ] as bool ;
909
896
final bool dryRun = parsedArguments['dry_run' ] as bool ;
910
- final Branch branch = fromBranchName (parsedArguments['branch' ] as String );
897
+ final Branch branch = Branch . fromName (parsedArguments['branch' ] as String );
911
898
final ArchiveCreator creator = ArchiveCreator (
912
899
tempDir,
913
900
outputDir,
0 commit comments