Skip to content

Commit a7ddb9b

Browse files
authored
readability refactor (#106026)
1 parent 873d343 commit a7ddb9b

File tree

2 files changed

+49
-35
lines changed

2 files changed

+49
-35
lines changed

dev/conductor/core/lib/src/globals.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ const String kLuciPackagingConsoleLink = 'https://ci.chromium.org/p/flutter/g/pa
2222

2323
const String kWebsiteReleasesUrl = 'https://docs.flutter.dev/development/tools/sdk/releases';
2424

25+
const String discordReleaseChannel =
26+
'https://discord.com/channels/608014603317936148/783492179922124850';
27+
28+
const String flutterReleaseHotline =
29+
'https://mail.google.com/chat/u/0/#chat/space/AAAA6RKcK2k';
30+
31+
const String hotfixToStableWiki =
32+
'https://github.com/flutter/flutter/wiki/Hotfixes-to-the-Stable-Channel';
33+
34+
const String flutterAnnounceGroup =
35+
'https://groups.google.com/g/flutter-announce';
36+
37+
const String hotfixDocumentationBestPractices =
38+
'https://github.com/flutter/flutter/wiki/Hotfix-Documentation-Best-Practices';
39+
2540
final RegExp releaseCandidateBranchRegex = RegExp(
2641
r'flutter-(\d+)\.(\d+)-candidate\.(\d+)',
2742
);

dev/conductor/core/lib/src/state.dart

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,36 @@ import 'dart:convert' show JsonEncoder, jsonDecode;
77
import 'package:file/file.dart' show File;
88
import 'package:platform/platform.dart';
99

10-
import './globals.dart';
10+
import './globals.dart' as globals;
1111
import './proto/conductor_state.pb.dart' as pb;
1212
import './proto/conductor_state.pbenum.dart' show ReleasePhase;
1313

1414
const String kStateFileName = '.flutter_conductor_state.json';
1515

16+
const String betaPostReleaseMsg = """
17+
'Ensure the following post release steps are complete:',
18+
'\t 1. Post announcement to discord',
19+
'\t\t Discord: ${globals.discordReleaseChannel}',
20+
'\t 2. Post announcement flutter release hotline chat room',
21+
'\t\t Chatroom: ${globals.flutterReleaseHotline}',
22+
""";
23+
24+
const String stablePostReleaseMsg = """
25+
'Ensure the following post release steps are complete:',
26+
'\t 1. Update hotfix to stable wiki following documentation best practices',
27+
'\t\t Wiki link: ${globals.hotfixToStableWiki}',
28+
'\t\t Best practices: ${globals.hotfixDocumentationBestPractices}',
29+
'\t 2. Post announcement to flutter-announce group',
30+
'\t\t Flutter Announce: ${globals.flutterAnnounceGroup}',
31+
'\t 3. Post announcement to discord',
32+
'\t\t Discord: ${globals.discordReleaseChannel}',
33+
'\t 4. Post announcement flutter release hotline chat room',
34+
'\t\t Chatroom: ${globals.flutterReleaseHotline}',
35+
""";
36+
1637
String luciConsoleLink(String channel, String groupName) {
1738
assert(
18-
kReleaseChannels.contains(channel),
39+
globals.kReleaseChannels.contains(channel),
1940
'channel $channel not recognized',
2041
);
2142
assert(
@@ -30,7 +51,8 @@ String luciConsoleLink(String channel, String groupName) {
3051
String defaultStateFilePath(Platform platform) {
3152
final String? home = platform.environment['HOME'];
3253
if (home == null) {
33-
throw ConductorException(r'Environment variable $HOME must be set!');
54+
throw globals.ConductorException(
55+
r'Environment variable $HOME must be set!');
3456
}
3557
return <String>[
3658
home,
@@ -134,7 +156,7 @@ String phaseInstructions(pb.ConductorState state) {
134156
'at ${state.engine.checkoutPath} in order:',
135157
for (final pb.Cherrypick cherrypick in state.engine.cherrypicks)
136158
'\t${cherrypick.trunkRevision}',
137-
'See $kReleaseDocumentationUrl for more information.',
159+
'See ${globals.kReleaseDocumentationUrl} for more information.',
138160
].join('\n');
139161
case ReleasePhase.CODESIGN_ENGINE_BINARIES:
140162
if (!requiresEnginePR(state)) {
@@ -143,7 +165,7 @@ String phaseInstructions(pb.ConductorState state) {
143165
}
144166
// User's working branch was pushed to their mirror, but a PR needs to be
145167
// opened on GitHub.
146-
final String newPrLink = getNewPrLink(
168+
final String newPrLink = globals.getNewPrLink(
147169
userName: githubAccount(state.engine.mirror.url),
148170
repoName: 'engine',
149171
state: state,
@@ -179,7 +201,7 @@ String phaseInstructions(pb.ConductorState state) {
179201
'PR is necessary.';
180202
}
181203

182-
final String newPrLink = getNewPrLink(
204+
final String newPrLink = globals.getNewPrLink(
183205
userName: githubAccount(state.framework.mirror.url),
184206
repoName: 'flutter',
185207
state: state,
@@ -195,44 +217,21 @@ String phaseInstructions(pb.ConductorState state) {
195217
case ReleasePhase.VERIFY_RELEASE:
196218
return 'Release archive packages must be verified on cloud storage: ${luciConsoleLink(state.releaseChannel, 'packaging')}';
197219
case ReleasePhase.RELEASE_COMPLETED:
198-
const String DISCORD_RELEASE_CHANNEL =
199-
'https://discord.com/channels/608014603317936148/783492179922124850';
200-
const String FLUTTER_RELEASE_HOTLINE =
201-
'https://mail.google.com/chat/u/0/#chat/space/AAAA6RKcK2k';
202-
const String HOTFIX_TO_STABLE_WIKI =
203-
'https://github.com/flutter/flutter/wiki/Hotfixes-to-the-Stable-Channel';
204-
const String FLUTTER_ANNOUNCE_GROUP =
205-
'https://groups.google.com/g/flutter-announce';
206-
const String DOCUMENTATION_BEST_PRACTICES =
207-
'https://github.com/flutter/flutter/wiki/Hotfix-Documentation-Best-Practices';
208220
if (state.releaseChannel == 'beta') {
209221
return <String>[
210-
'Ensure the following post release steps are complete:',
211-
'\t 1. Post announcement to discord',
212-
'\t\t Discord: $DISCORD_RELEASE_CHANNEL',
213-
'\t 2. Post announcement flutter release hotline chat room',
214-
'\t\t Chatroom: $FLUTTER_RELEASE_HOTLINE',
222+
betaPostReleaseMsg,
215223
'-----------------------------------------------------------------------',
216224
'This release has been completed.',
217225
].join('\n');
218226
}
219227
return <String>[
220-
'Ensure the following post release steps are complete:',
221-
'\t 1. Update hotfix to stable wiki following documentation best practices',
222-
'\t\t Wiki link: $HOTFIX_TO_STABLE_WIKI',
223-
'\t\t Best practices: $DOCUMENTATION_BEST_PRACTICES',
224-
'\t 2. Post announcement to flutter-announce group',
225-
'\t\t Flutter Announce: $FLUTTER_ANNOUNCE_GROUP',
226-
'\t 3. Post announcement to discord',
227-
'\t\t Discord: $DISCORD_RELEASE_CHANNEL',
228-
'\t 4. Post announcement flutter release hotline chat room',
229-
'\t\t Chatroom: $FLUTTER_RELEASE_HOTLINE',
228+
stablePostReleaseMsg,
230229
'-----------------------------------------------------------------------',
231230
'This release has been completed.',
232231
].join('\n');
233232
}
234233
// For analyzer
235-
throw ConductorException('Unimplemented phase ${state.currentPhase}');
234+
throw globals.ConductorException('Unimplemented phase ${state.currentPhase}');
236235
}
237236

238237
/// Regex pattern for git remote host URLs.
@@ -250,13 +249,13 @@ String githubAccount(String remoteUrl) {
250249
final String engineUrl = remoteUrl;
251250
final RegExpMatch? match = githubRemotePattern.firstMatch(engineUrl);
252251
if (match == null) {
253-
throw ConductorException(
252+
throw globals.ConductorException(
254253
'Cannot determine the GitHub account from $engineUrl',
255254
);
256255
}
257256
final String? accountName = match.group(2);
258257
if (accountName == null || accountName.isEmpty) {
259-
throw ConductorException(
258+
throw globals.ConductorException(
260259
'Cannot determine the GitHub account from $match',
261260
);
262261
}
@@ -271,7 +270,7 @@ ReleasePhase getNextPhase(ReleasePhase currentPhase) {
271270
assert(currentPhase != null);
272271
final ReleasePhase? nextPhase = ReleasePhase.valueOf(currentPhase.value + 1);
273272
if (nextPhase == null) {
274-
throw ConductorException('There is no next ReleasePhase!');
273+
throw globals.ConductorException('There is no next ReleasePhase!');
275274
}
276275
return nextPhase;
277276
}

0 commit comments

Comments
 (0)