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