From ad470f6bae8ddc1dbad66ff361368c07910350b8 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 1 Dec 2021 13:19:05 -0500 Subject: [PATCH] [conductor] channel constants refactor (#94220) --- dev/conductor/core/lib/src/globals.dart | 21 +++++++++------------ dev/conductor/core/lib/src/start.dart | 4 ++-- dev/conductor/core/lib/src/state.dart | 2 +- dev/conductor/core/lib/src/version.dart | 4 ++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/dev/conductor/core/lib/src/globals.dart b/dev/conductor/core/lib/src/globals.dart index 89bde9a965..9c010c8a5e 100644 --- a/dev/conductor/core/lib/src/globals.dart +++ b/dev/conductor/core/lib/src/globals.dart @@ -12,12 +12,11 @@ const String gsutilBinary = 'gsutil.py'; const String kFrameworkDefaultBranch = 'master'; const String kForceFlag = 'force'; -const List kReleaseChannels = [ - 'stable', - 'beta', - 'dev', - FrameworkRepository.defaultBranch, -]; +const List kBaseReleaseChannels = ['stable', 'beta', 'dev']; + +const List kReleaseChannels = [...kBaseReleaseChannels, FrameworkRepository.defaultBranch]; + +const List KReleaseIncrements = ['y', 'z', 'm', 'n']; const String kReleaseDocumentationUrl = 'https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process'; @@ -80,9 +79,8 @@ String? getValueFromEnvOrArgs( if (allowNull) { return null; } - throw ConductorException( - 'Expected either the CLI arg --$name or the environment variable $envName ' - 'to be provided!'); + throw ConductorException('Expected either the CLI arg --$name or the environment variable $envName ' + 'to be provided!'); } bool getBoolFromEnvOrArgs( @@ -120,9 +118,8 @@ List getValuesFromEnvOrArgs( return argValues; } - throw ConductorException( - 'Expected either the CLI arg --$name or the environment variable $envName ' - 'to be provided!'); + throw ConductorException('Expected either the CLI arg --$name or the environment variable $envName ' + 'to be provided!'); } /// Translate CLI arg names to env variable names. diff --git a/dev/conductor/core/lib/src/start.dart b/dev/conductor/core/lib/src/start.dart index 48dfabb507..4135441938 100644 --- a/dev/conductor/core/lib/src/start.dart +++ b/dev/conductor/core/lib/src/start.dart @@ -48,7 +48,7 @@ class StartCommand extends Command { argParser.addOption( kReleaseOption, help: 'The target release channel for the release.', - allowed: ['stable', 'beta', 'dev'], + allowed: kBaseReleaseChannels, ); argParser.addOption( kFrameworkUpstreamOption, @@ -93,7 +93,7 @@ class StartCommand extends Command { kIncrementOption, help: 'Specifies which part of the x.y.z version number to increment. Required.', valueHelp: 'level', - allowed: ['y', 'z', 'm', 'n'], + allowed: KReleaseIncrements, allowedHelp: { 'y': 'Indicates the first dev release after a beta release.', 'z': 'Indicates a hotfix to a stable release.', diff --git a/dev/conductor/core/lib/src/state.dart b/dev/conductor/core/lib/src/state.dart index c76a19e967..b56a4db315 100644 --- a/dev/conductor/core/lib/src/state.dart +++ b/dev/conductor/core/lib/src/state.dart @@ -15,7 +15,7 @@ const String kStateFileName = '.flutter_conductor_state.json'; String luciConsoleLink(String channel, String groupName) { assert( - ['stable', 'beta', 'dev', 'master'].contains(channel), + kReleaseChannels.contains(channel), 'channel $channel not recognized', ); assert( diff --git a/dev/conductor/core/lib/src/version.dart b/dev/conductor/core/lib/src/version.dart index 76c6005b9e..85b21fde6c 100644 --- a/dev/conductor/core/lib/src/version.dart +++ b/dev/conductor/core/lib/src/version.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import './globals.dart' show releaseCandidateBranchRegex, ConductorException; +import './globals.dart' show ConductorException, KReleaseIncrements, releaseCandidateBranchRegex; /// Possible string formats that `flutter --version` can return. enum VersionType { @@ -262,7 +262,7 @@ class Version { /// Will throw a [ConductorException] if the version is not possible given the /// [candidateBranch] and [incrementLetter]. void ensureValid(String candidateBranch, String incrementLetter) { - if (!const {'y', 'z', 'm', 'n'}.contains(incrementLetter)) { + if (!KReleaseIncrements.contains(incrementLetter)) { throw ConductorException('Invalid incrementLetter: $incrementLetter'); } final RegExpMatch? branchMatch = releaseCandidateBranchRegex.firstMatch(candidateBranch);