Skip to content

Commit

Permalink
fix: improve flutter minimum support version check for windows (#2747)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman authored Jan 9, 2025
1 parent b946e89 commit 59749a0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ To change the version of this release, change your app's version in your pubspec
if (flutterVersionArg != null) {
final version =
await shorebirdFlutter.resolveFlutterVersion(flutterVersionArg);
if (version != null && version < minimumSupportedWindowsFlutterVersion) {
final gitHash =
await shorebirdFlutter.getRevisionForVersion(flutterVersionArg);
if (version != null &&
version < minimumSupportedWindowsFlutterVersion &&
!windowsFlutterGitHashesBelowMinVersion.contains(gitHash)) {
logger.err(
'''
Windows releases are not supported with Flutter versions older than $minimumSupportedWindowsFlutterVersion.
Expand Down
7 changes: 6 additions & 1 deletion packages/shorebird_cli/lib/src/platform/windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import 'package:pub_semver/pub_semver.dart';
const primaryWindowsReleaseArtifactArch = 'win_archive';

/// The minimum allowed Flutter version for creating Windows releases.
final minimumSupportedWindowsFlutterVersion = Version(3, 27, 1);
final minimumSupportedWindowsFlutterVersion = Version(3, 27, 2);

/// Revisions of Flutter 3.27.1 that support windows.
const windowsFlutterGitHashesBelowMinVersion = {
'56228c343d6c7fd3e1e548dbb290f9713bb22aa9'
};

/// A warning message printed at the start of `shorebird release windows` and
/// `shorebird patch windows` commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,12 @@ To change the version of this release, change your app's version in your pubspec
),
).thenAnswer((_) async {});
when(() => argResults['flutter-version'] as String?)
.thenReturn('1.2.3');
when(() => shorebirdFlutter.resolveFlutterVersion('1.2.3'))
.thenAnswer((_) async => Version(1, 2, 3));
when(() => shorebirdFlutter.getVersionAndRevision())
.thenAnswer((_) async => '3.27.1');
.thenReturn('3.27.1');
when(() => shorebirdFlutter.resolveFlutterVersion('3.27.1'))
.thenAnswer((_) async => Version(3, 27, 1));
when(
() => shorebirdFlutter.getRevisionForVersion(any()),
).thenAnswer((_) async => 'deadbeef');
});

test('logs error and exits with usage err', () async {
Expand All @@ -243,6 +244,22 @@ For more information see: ${supportedFlutterVersionsUrl.toLink()}''',
),
).called(1);
});

group('when flutter version is 3.27.1 but hash is supported', () {
setUp(() {
when(
() => shorebirdFlutter.getRevisionForVersion(any()),
).thenAnswer(
(_) async => windowsFlutterGitHashesBelowMinVersion.first);
});

test('completes normally', () async {
await expectLater(
runWithOverrides(releaser.assertPreconditions),
completes,
);
});
});
});
});

Expand Down

0 comments on commit 59749a0

Please sign in to comment.