Unverified Commit ad470f6b authored by Alex's avatar Alex Committed by GitHub

[conductor] channel constants refactor (#94220)

parent ed8468b9
...@@ -12,12 +12,11 @@ const String gsutilBinary = 'gsutil.py'; ...@@ -12,12 +12,11 @@ const String gsutilBinary = 'gsutil.py';
const String kFrameworkDefaultBranch = 'master'; const String kFrameworkDefaultBranch = 'master';
const String kForceFlag = 'force'; const String kForceFlag = 'force';
const List<String> kReleaseChannels = <String>[ const List<String> kBaseReleaseChannels = <String>['stable', 'beta', 'dev'];
'stable',
'beta', const List<String> kReleaseChannels = <String>[...kBaseReleaseChannels, FrameworkRepository.defaultBranch];
'dev',
FrameworkRepository.defaultBranch, const List<String> KReleaseIncrements = <String>['y', 'z', 'm', 'n'];
];
const String kReleaseDocumentationUrl = 'https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process'; const String kReleaseDocumentationUrl = 'https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process';
...@@ -80,9 +79,8 @@ String? getValueFromEnvOrArgs( ...@@ -80,9 +79,8 @@ String? getValueFromEnvOrArgs(
if (allowNull) { if (allowNull) {
return null; return null;
} }
throw ConductorException( throw ConductorException('Expected either the CLI arg --$name or the environment variable $envName '
'Expected either the CLI arg --$name or the environment variable $envName ' 'to be provided!');
'to be provided!');
} }
bool getBoolFromEnvOrArgs( bool getBoolFromEnvOrArgs(
...@@ -120,9 +118,8 @@ List<String> getValuesFromEnvOrArgs( ...@@ -120,9 +118,8 @@ List<String> getValuesFromEnvOrArgs(
return argValues; return argValues;
} }
throw ConductorException( throw ConductorException('Expected either the CLI arg --$name or the environment variable $envName '
'Expected either the CLI arg --$name or the environment variable $envName ' 'to be provided!');
'to be provided!');
} }
/// Translate CLI arg names to env variable names. /// Translate CLI arg names to env variable names.
......
...@@ -48,7 +48,7 @@ class StartCommand extends Command<void> { ...@@ -48,7 +48,7 @@ class StartCommand extends Command<void> {
argParser.addOption( argParser.addOption(
kReleaseOption, kReleaseOption,
help: 'The target release channel for the release.', help: 'The target release channel for the release.',
allowed: <String>['stable', 'beta', 'dev'], allowed: kBaseReleaseChannels,
); );
argParser.addOption( argParser.addOption(
kFrameworkUpstreamOption, kFrameworkUpstreamOption,
...@@ -93,7 +93,7 @@ class StartCommand extends Command<void> { ...@@ -93,7 +93,7 @@ class StartCommand extends Command<void> {
kIncrementOption, kIncrementOption,
help: 'Specifies which part of the x.y.z version number to increment. Required.', help: 'Specifies which part of the x.y.z version number to increment. Required.',
valueHelp: 'level', valueHelp: 'level',
allowed: <String>['y', 'z', 'm', 'n'], allowed: KReleaseIncrements,
allowedHelp: <String, String>{ allowedHelp: <String, String>{
'y': 'Indicates the first dev release after a beta release.', 'y': 'Indicates the first dev release after a beta release.',
'z': 'Indicates a hotfix to a stable release.', 'z': 'Indicates a hotfix to a stable release.',
......
...@@ -15,7 +15,7 @@ const String kStateFileName = '.flutter_conductor_state.json'; ...@@ -15,7 +15,7 @@ const String kStateFileName = '.flutter_conductor_state.json';
String luciConsoleLink(String channel, String groupName) { String luciConsoleLink(String channel, String groupName) {
assert( assert(
<String>['stable', 'beta', 'dev', 'master'].contains(channel), kReleaseChannels.contains(channel),
'channel $channel not recognized', 'channel $channel not recognized',
); );
assert( assert(
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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. /// Possible string formats that `flutter --version` can return.
enum VersionType { enum VersionType {
...@@ -262,7 +262,7 @@ class Version { ...@@ -262,7 +262,7 @@ class Version {
/// Will throw a [ConductorException] if the version is not possible given the /// Will throw a [ConductorException] if the version is not possible given the
/// [candidateBranch] and [incrementLetter]. /// [candidateBranch] and [incrementLetter].
void ensureValid(String candidateBranch, String incrementLetter) { void ensureValid(String candidateBranch, String incrementLetter) {
if (!const <String>{'y', 'z', 'm', 'n'}.contains(incrementLetter)) { if (!KReleaseIncrements.contains(incrementLetter)) {
throw ConductorException('Invalid incrementLetter: $incrementLetter'); throw ConductorException('Invalid incrementLetter: $incrementLetter');
} }
final RegExpMatch? branchMatch = releaseCandidateBranchRegex.firstMatch(candidateBranch); final RegExpMatch? branchMatch = releaseCandidateBranchRegex.firstMatch(candidateBranch);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment