Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve flutter minimum support version check for windows #2747

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading