From 59749a0cfd3ef6f8ce18e67125fc07c9f9764bca Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Thu, 9 Jan 2025 17:39:00 -0500 Subject: [PATCH] fix: improve flutter minimum support version check for windows (#2747) --- .../commands/release/windows_releaser.dart | 6 ++++- .../lib/src/platform/windows.dart | 7 ++++- .../release/windows_releaser_test.dart | 27 +++++++++++++++---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/packages/shorebird_cli/lib/src/commands/release/windows_releaser.dart b/packages/shorebird_cli/lib/src/commands/release/windows_releaser.dart index 062b3eeaf..52f675f16 100644 --- a/packages/shorebird_cli/lib/src/commands/release/windows_releaser.dart +++ b/packages/shorebird_cli/lib/src/commands/release/windows_releaser.dart @@ -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. diff --git a/packages/shorebird_cli/lib/src/platform/windows.dart b/packages/shorebird_cli/lib/src/platform/windows.dart index 2cc1753ea..37e3285b6 100644 --- a/packages/shorebird_cli/lib/src/platform/windows.dart +++ b/packages/shorebird_cli/lib/src/platform/windows.dart @@ -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. diff --git a/packages/shorebird_cli/test/src/commands/release/windows_releaser_test.dart b/packages/shorebird_cli/test/src/commands/release/windows_releaser_test.dart index 12b551713..21c754858 100644 --- a/packages/shorebird_cli/test/src/commands/release/windows_releaser_test.dart +++ b/packages/shorebird_cli/test/src/commands/release/windows_releaser_test.dart @@ -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 { @@ -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, + ); + }); + }); }); });