Unverified Commit a1d3edc4 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Twiggle bit to exclude dev and beta from desktop and web (#35221)

parent b43b8bab
...@@ -103,7 +103,7 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -103,7 +103,7 @@ class BuildBundleCommand extends BuildSubCommand {
case TargetPlatform.darwin_x64: case TargetPlatform.darwin_x64:
case TargetPlatform.windows_x64: case TargetPlatform.windows_x64:
case TargetPlatform.linux_x64: case TargetPlatform.linux_x64:
if (FlutterVersion.instance.isStable) { if (!FlutterVersion.instance.isMaster) {
throwToolExit('$targetPlatform is not supported on stable Flutter.'); throwToolExit('$targetPlatform is not supported on stable Flutter.');
} }
break; break;
......
...@@ -613,7 +613,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi ...@@ -613,7 +613,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
'iosLanguage': iosLanguage, 'iosLanguage': iosLanguage,
'flutterRevision': FlutterVersion.instance.frameworkRevision, 'flutterRevision': FlutterVersion.instance.frameworkRevision,
'flutterChannel': FlutterVersion.instance.channel, 'flutterChannel': FlutterVersion.instance.channel,
'web': web && !FlutterVersion.instance.isStable, 'web': web && FlutterVersion.instance.isMaster
}; };
} }
......
...@@ -50,7 +50,7 @@ class PrecacheCommand extends FlutterCommand { ...@@ -50,7 +50,7 @@ class PrecacheCommand extends FlutterCommand {
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{}; final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{};
for (DevelopmentArtifact artifact in DevelopmentArtifact.values) { for (DevelopmentArtifact artifact in DevelopmentArtifact.values) {
// Don't include unstable artifacts on stable branches. // Don't include unstable artifacts on stable branches.
if (FlutterVersion.instance.isStable && artifact.unstable) { if (!FlutterVersion.instance.isMaster && artifact.unstable) {
continue; continue;
} }
if (argResults[artifact.name]) { if (argResults[artifact.name]) {
......
...@@ -352,7 +352,7 @@ class RunCommand extends RunCommandBase { ...@@ -352,7 +352,7 @@ class RunCommand extends RunCommandBase {
); );
} }
if (argResults['dart-flags'] != null && FlutterVersion.instance.isStable) { if (argResults['dart-flags'] != null && !FlutterVersion.instance.isMaster) {
throw UsageException('--dart-flags is not available on the stable ' throw UsageException('--dart-flags is not available on the stable '
'channel.', null); 'channel.', null);
} }
...@@ -411,7 +411,7 @@ class RunCommand extends RunCommandBase { ...@@ -411,7 +411,7 @@ class RunCommand extends RunCommandBase {
} }
// Only support "web mode" on non-stable branches with a single web device // Only support "web mode" on non-stable branches with a single web device
// in a "hot mode". // in a "hot mode".
final bool webMode = !FlutterVersion.instance.isStable final bool webMode = FlutterVersion.instance.isMaster
&& devices.length == 1 && devices.length == 1
&& await devices.single.targetPlatform == TargetPlatform.web_javascript; && await devices.single.targetPlatform == TargetPlatform.web_javascript;
......
...@@ -26,9 +26,9 @@ bool get flutterDesktopEnabled { ...@@ -26,9 +26,9 @@ bool get flutterDesktopEnabled {
if (isRunningFromDaemon) { if (isRunningFromDaemon) {
final bool platformEnabled = platform final bool platformEnabled = platform
.environment['ENABLE_FLUTTER_DESKTOP']?.toLowerCase() == 'true'; .environment['ENABLE_FLUTTER_DESKTOP']?.toLowerCase() == 'true';
return platformEnabled && !FlutterVersion.instance.isStable; return platformEnabled && FlutterVersion.instance.isMaster;
} }
return !FlutterVersion.instance.isStable; return FlutterVersion.instance.isMaster;
} }
/// Kills a process on linux or macOS. /// Kills a process on linux or macOS.
......
...@@ -555,7 +555,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -555,7 +555,7 @@ abstract class FlutterCommand extends Command<void> {
Future<void> validateCommand() async { Future<void> validateCommand() async {
// If we're on a stable branch, then don't allow the usage of // If we're on a stable branch, then don't allow the usage of
// "experimental" features. // "experimental" features.
if (isExperimental && FlutterVersion.instance.isStable) { if (isExperimental && !FlutterVersion.instance.isMaster) {
throwToolExit('Experimental feature $name is not supported on stable branches'); throwToolExit('Experimental feature $name is not supported on stable branches');
} }
...@@ -651,17 +651,17 @@ DevelopmentArtifact _artifactFromTargetPlatform(TargetPlatform targetPlatform) { ...@@ -651,17 +651,17 @@ DevelopmentArtifact _artifactFromTargetPlatform(TargetPlatform targetPlatform) {
case TargetPlatform.ios: case TargetPlatform.ios:
return DevelopmentArtifact.iOS; return DevelopmentArtifact.iOS;
case TargetPlatform.darwin_x64: case TargetPlatform.darwin_x64:
if (!FlutterVersion.instance.isStable) { if (FlutterVersion.instance.isMaster) {
return DevelopmentArtifact.macOS; return DevelopmentArtifact.macOS;
} }
return null; return null;
case TargetPlatform.windows_x64: case TargetPlatform.windows_x64:
if (!FlutterVersion.instance.isStable) { if (!FlutterVersion.instance.isMaster) {
return DevelopmentArtifact.windows; return DevelopmentArtifact.windows;
} }
return null; return null;
case TargetPlatform.linux_x64: case TargetPlatform.linux_x64:
if (!FlutterVersion.instance.isStable) { if (!FlutterVersion.instance.isMaster) {
return DevelopmentArtifact.linux; return DevelopmentArtifact.linux;
} }
return null; return null;
......
...@@ -32,9 +32,10 @@ class FlutterVersion { ...@@ -32,9 +32,10 @@ class FlutterVersion {
return _repositoryUrl; return _repositoryUrl;
} }
/// Whether we are currently on the stable branch. /// Whether we are currently on the master branch.
bool get isStable { bool get isMaster {
return getBranchName() == 'stable'; final String branchName = getBranchName();
return !<String>['dev', 'beta', 'stable'].contains(branchName);
} }
static const Set<String> officialChannels = <String>{ static const Set<String> officialChannels = <String>{
......
...@@ -24,9 +24,9 @@ bool get flutterWebEnabled { ...@@ -24,9 +24,9 @@ bool get flutterWebEnabled {
if (isRunningFromDaemon) { if (isRunningFromDaemon) {
final bool platformEnabled = platform final bool platformEnabled = platform
.environment['FLUTTER_WEB']?.toLowerCase() == 'true'; .environment['FLUTTER_WEB']?.toLowerCase() == 'true';
return platformEnabled && !FlutterVersion.instance.isStable; return platformEnabled && FlutterVersion.instance.isMaster;
} }
return !FlutterVersion.instance.isStable; return FlutterVersion.instance.isMaster;
} }
/// The web workflow instance. /// The web workflow instance.
......
...@@ -93,5 +93,5 @@ class MockPlatform extends Mock implements Platform { ...@@ -93,5 +93,5 @@ class MockPlatform extends Mock implements Platform {
} }
class MockFlutterVersion extends Mock implements FlutterVersion { class MockFlutterVersion extends Mock implements FlutterVersion {
@override @override
bool get isStable => false; bool get isMaster => true;
} }
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
}); });
final MockFlutterVersion flutterVersion = MockFlutterVersion(); final MockFlutterVersion flutterVersion = MockFlutterVersion();
when(flutterVersion.isStable).thenReturn(true); when(flutterVersion.isMaster).thenReturn(false);
testUsingContext('Adds artifact flags to requested artifacts on stable', () async { testUsingContext('Adds artifact flags to requested artifacts on stable', () async {
// Release lock between test cases. // Release lock between test cases.
......
...@@ -201,7 +201,7 @@ class TestRunCommand extends RunCommand { ...@@ -201,7 +201,7 @@ class TestRunCommand extends RunCommand {
class MockStableFlutterVersion extends MockFlutterVersion { class MockStableFlutterVersion extends MockFlutterVersion {
@override @override
bool get isStable => true; bool get isMaster => false;
} }
class FakeDevice extends Fake implements Device { class FakeDevice extends Fake implements Device {
......
...@@ -274,8 +274,8 @@ void main() { ...@@ -274,8 +274,8 @@ void main() {
final MockVersion stableVersion = MockVersion(); final MockVersion stableVersion = MockVersion();
final MockVersion betaVersion = MockVersion(); final MockVersion betaVersion = MockVersion();
final FakeCommand fakeCommand = FakeCommand(); final FakeCommand fakeCommand = FakeCommand();
when(stableVersion.isStable).thenReturn(true); when(stableVersion.isMaster).thenReturn(false);
when(betaVersion.isStable).thenReturn(false); when(betaVersion.isMaster).thenReturn(true);
testUsingContext('Can be disabled on stable branch', () async { testUsingContext('Can be disabled on stable branch', () async {
expect(() => fakeCommand.run(), throwsA(isA<ToolExit>())); expect(() => fakeCommand.run(), throwsA(isA<ToolExit>()));
......
...@@ -348,7 +348,7 @@ class MockFlutterVersion extends Mock implements FlutterVersion { ...@@ -348,7 +348,7 @@ class MockFlutterVersion extends Mock implements FlutterVersion {
final bool _isStable; final bool _isStable;
@override @override
bool get isStable => _isStable; bool get isMaster => !_isStable;
} }
class MockClock extends Mock implements SystemClock {} class MockClock extends Mock implements SystemClock {}
......
...@@ -96,8 +96,10 @@ void main() { ...@@ -96,8 +96,10 @@ void main() {
class MockFlutterVersion extends Mock implements FlutterVersion { class MockFlutterVersion extends Mock implements FlutterVersion {
MockFlutterVersion(this.isStable); MockFlutterVersion(this.isStable);
@override
final bool isStable; final bool isStable;
@override
bool get isMaster => !isStable;
} }
class MockProcessManager extends Mock implements ProcessManager {} class MockProcessManager extends Mock implements ProcessManager {}
......
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