@@ -52,29 +52,19 @@ class PreparePackageException implements Exception {
5252 }
5353}
5454
55- enum Branch { dev, beta, stable }
55+ enum Branch {
56+ beta,
57+ stable;
5658
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+ }
7868 }
7969}
8070
@@ -304,9 +294,6 @@ class ArchiveCreator {
304294 .trim ().split (' ' ).last.replaceAll ('"' , '' ).split ('_' )[1 ];
305295 })();
306296
307- /// Get the name of the channel as a string.
308- String get branchName => getBranchName (branch);
309-
310297 /// Returns a default archive name when given a Git revision.
311298 /// Used when an output filename is not given.
312299 Future <String > get _archiveName async {
@@ -321,7 +308,8 @@ class ArchiveCreator {
321308 // unpacking it!) So, we use .zip for Mac, and the files are about
322309 // 220MB larger than they need to be. :-(
323310 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 ' ;
325313 }
326314
327315 /// Checks out the flutter repo and prepares it for other operations.
@@ -425,7 +413,7 @@ class ArchiveCreator {
425413 // We want the user to start out the in the specified branch instead of a
426414 // detached head. To do that, we need to make sure the branch points at the
427415 // desired revision.
428- await _runGit (< String > ['clone' , '-b' , branchName , gobMirror], workingDirectory: tempDir);
416+ await _runGit (< String > ['clone' , '-b' , branch.name , gobMirror], workingDirectory: tempDir);
429417 await _runGit (< String > ['reset' , '--hard' , revision]);
430418
431419 // Make the origin point to github instead of the chromium mirror.
@@ -624,8 +612,7 @@ class ArchivePublisher {
624612 final File outputFile;
625613 final ProcessRunner _processRunner;
626614 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 )}' ;
629616 static String getMetadataFilename (Platform platform) => 'releases_${platform .operatingSystem .toLowerCase ()}.json' ;
630617
631618 Future <String > _getChecksum (File archiveFile) async {
@@ -666,14 +653,14 @@ class ArchivePublisher {
666653 if (! jsonData.containsKey ('current_release' )) {
667654 jsonData['current_release' ] = < String , String > {};
668655 }
669- (jsonData['current_release' ] as Map <String , dynamic >)[branchName ] = revision;
656+ (jsonData['current_release' ] as Map <String , dynamic >)[branch.name ] = revision;
670657 if (! jsonData.containsKey ('releases' )) {
671658 jsonData['releases' ] = < Map <String , dynamic >> [];
672659 }
673660
674661 final Map <String , dynamic > newEntry = < String , dynamic > {};
675662 newEntry['hash' ] = revision;
676- newEntry['channel' ] = branchName ;
663+ newEntry['channel' ] = branch.name ;
677664 newEntry['version' ] = version[frameworkVersionTag];
678665 newEntry['dart_sdk_version' ] = version[dartVersionTag];
679666 newEntry['dart_sdk_arch' ] = version[dartTargetArchTag];
@@ -825,7 +812,7 @@ Future<void> main(List<String> rawArguments) async {
825812 'archive with. Must be the full 40-character hash. Required.' );
826813 argParser.addOption (
827814 'branch' ,
828- allowed: Branch .values.map <String >((Branch branch) => getBranchName ( branch) ),
815+ allowed: Branch .values.map <String >((Branch branch) => branch.name ),
829816 help: 'The Flutter branch to build the archive with. Required.' ,
830817 );
831818 argParser.addOption (
@@ -907,7 +894,7 @@ Future<void> main(List<String> rawArguments) async {
907894
908895 final bool publish = parsedArguments['publish' ] as bool ;
909896 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 );
911898 final ArchiveCreator creator = ArchiveCreator (
912899 tempDir,
913900 outputDir,
0 commit comments