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: Fix FormatException caused by '@' in Custom Flutter Version #808

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions lib/src/models/flutter_version_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ class FlutterVersion with FlutterVersionMappable {
: type = VersionType.release;

factory FlutterVersion.parse(String version) {
final parts = version.split('@');
// Check if its custom.
if (version.startsWith('custom_')) {
return FlutterVersion.custom(version);
}

final parts = version.split('@');
if (parts.length == 2) {
final channel = parts.last;
if (kFlutterChannels.contains(channel)) {
Expand All @@ -68,10 +72,6 @@ class FlutterVersion with FlutterVersionMappable {

throw FormatException('Invalid version format');
}
// Check if its custom.
if (version.startsWith('custom_')) {
return FlutterVersion.custom(version);
}

// Check if its commit
if (isGitCommit(version)) {
Expand Down
34 changes: 32 additions & 2 deletions releases_linux.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "3e493a3e4d0a5c99fa7da51faae354e95a9a1abe",
"beta": "45459707c029b168a61dcde1f1c1d64df9d529af",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "17025dd88227cd9532c33fa78f5250d548d87e9a"
"stable": "c519ee916eaeb88923e67befb89c0f1dabfa83e6"
},
"releases": [
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-01-27T20:27:45.101671Z",
"archive": "beta/linux/flutter_linux_3.29.0-0.2.pre-beta.tar.xz",
"sha256": "4affbc9f2b8c3b83b086471a46a7c908afca381d78339e5cba42982e66b3191b"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-21T20:35:29.161615Z",
"archive": "stable/linux/flutter_linux_3.27.3-stable.tar.xz",
"sha256": "b5b60424c51ff11b62cc2fad44cdb334c7ac49cb737ae87451c9c09e13aa01d6"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-13T22:31:44.493761Z",
"archive": "stable/linux/flutter_linux_3.27.2-stable.tar.xz",
"sha256": "5ba77ace2b2748a251473a89785e8b8305cefd3e9dafafd7a197cda0b803c55a"
},
{
"hash": "17025dd88227cd9532c33fa78f5250d548d87e9a",
"channel": "stable",
Expand Down
76 changes: 68 additions & 8 deletions releases_macos.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "3e493a3e4d0a5c99fa7da51faae354e95a9a1abe",
"beta": "45459707c029b168a61dcde1f1c1d64df9d529af",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "17025dd88227cd9532c33fa78f5250d548d87e9a"
"stable": "c519ee916eaeb88923e67befb89c0f1dabfa83e6"
},
"releases": [
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-01-27T20:19:00.875075Z",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Release dates are set in the future

The release dates for new entries are set in 2025, which is beyond the current date. This could cause issues with release management and version comparisons.

Update the release dates to use the correct current or past dates. For example:

-      "release_date": "2025-01-27T20:19:00.875075Z",
+      "release_date": "2024-01-27T20:19:00.875075Z"

Also applies to: 25-25, 35-35, 45-45, 55-55, 65-65

"archive": "beta/macos/flutter_macos_3.29.0-0.2.pre-beta.zip",
"sha256": "52132c40c7f71a1ab5b621020505a5b95c2413ed5c1326c250c9e0272d16ff3c"
},
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "arm64",
"release_date": "2025-01-27T20:12:08.729699Z",
"archive": "beta/macos/flutter_macos_arm64_3.29.0-0.2.pre-beta.zip",
"sha256": "6d0e3140150f9942bbacef7a336a15d7791935780fd316afb195926fdf006bf5"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-21T20:33:49.233815Z",
"archive": "stable/macos/flutter_macos_3.27.3-stable.zip",
"sha256": "b1117c4e1a80ae13a1ba6281b8141e429cb62fc5382386e2a78e00d12a423706"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "arm64",
"release_date": "2025-01-21T20:27:29.326710Z",
"archive": "stable/macos/flutter_macos_arm64_3.27.3-stable.zip",
"sha256": "20d1ca79dad65f9f9fcd4c31bdbbbcc2237aa0cd384a83d6dff795d44fe1039a"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-13T22:27:04.890409Z",
"archive": "stable/macos/flutter_macos_3.27.2-stable.zip",
"sha256": "26c96cd7e4682ffc15a741d2963b15b87123875cb2fbb8ac5dbdc1aee41f5388"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "arm64",
"release_date": "2025-01-13T22:20:35.633578Z",
"archive": "stable/macos/flutter_macos_arm64_3.27.2-stable.zip",
"sha256": "e8333d7f7d3718d80b50445017a426fda3ffa1936dfed7753ec74e43c90becd4"
},
{
"hash": "17025dd88227cd9532c33fa78f5250d548d87e9a",
"channel": "stable",
Expand Down Expand Up @@ -251,20 +311,20 @@
"channel": "stable",
"version": "3.24.0",
"dart_sdk_version": "3.5.0",
"dart_sdk_arch": "arm64",
"dart_sdk_arch": "x64",
"release_date": "2024-08-06T17:39:54.402003Z",
"archive": "stable/macos/flutter_macos_arm64_3.24.0-stable.zip",
"sha256": "3c443985c9cda5f6959a274caddfeb38e11777fc8ed8a69ae700a1485e6dd258"
"archive": "stable/macos/flutter_macos_3.24.0-stable.zip",
"sha256": "94ab73b88a4a996c4eb930644838d0863918cbc4a039a8144ccafe2e1cacd304"
},
{
"hash": "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819",
"channel": "stable",
"version": "3.24.0",
"dart_sdk_version": "3.5.0",
"dart_sdk_arch": "x64",
"dart_sdk_arch": "arm64",
"release_date": "2024-08-06T17:39:54.402003Z",
"archive": "stable/macos/flutter_macos_3.24.0-stable.zip",
"sha256": "94ab73b88a4a996c4eb930644838d0863918cbc4a039a8144ccafe2e1cacd304"
"archive": "stable/macos/flutter_macos_arm64_3.24.0-stable.zip",
"sha256": "3c443985c9cda5f6959a274caddfeb38e11777fc8ed8a69ae700a1485e6dd258"
},
{
"hash": "7c6b7e9ca485f7eaaed913c6bb50f4be6da47e30",
Expand Down
34 changes: 32 additions & 2 deletions releases_windows.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "3e493a3e4d0a5c99fa7da51faae354e95a9a1abe",
"beta": "45459707c029b168a61dcde1f1c1d64df9d529af",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "17025dd88227cd9532c33fa78f5250d548d87e9a"
"stable": "c519ee916eaeb88923e67befb89c0f1dabfa83e6"
},
"releases": [
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-01-27T20:22:33.061347Z",
"archive": "beta/windows/flutter_windows_3.29.0-0.2.pre-beta.zip",
"sha256": "7c095ca994e8f226a60ca433861ae466eeb0a36cc97838ab1b6d1ad1c58be031"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-21T20:47:44.369846Z",
"archive": "stable/windows/flutter_windows_3.27.3-stable.zip",
"sha256": "cd1a66704fe075a8c8bc2c558dd4dcec171ba396a84aea88e3d48c23852d62c3"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-13T22:30:36.187540Z",
"archive": "stable/windows/flutter_windows_3.27.2-stable.zip",
"sha256": "ed4ae71a30dfdd04a8a1053d9e354314ab95f4731930d39d9b656d36209cc41d"
},
{
"hash": "17025dd88227cd9532c33fa78f5250d548d87e9a",
"channel": "stable",
Expand Down
20 changes: 20 additions & 0 deletions test/models/flutter_version_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ void main() {
expect(version.type, VersionType.custom);
});

test('custom constructor', () {
final version = FlutterVersion.custom('custom_3.7.0@huawei');
expect(version.name, 'custom_3.7.0@huawei');
expect(version.releaseFromChannel, isNull);
expect(version.type, VersionType.custom);
});

test('release constructor', () {
final version =
FlutterVersion.release('1.0.0', releaseFromChannel: 'stable');
Expand Down Expand Up @@ -109,6 +116,13 @@ void main() {
expect(version.type, VersionType.custom);
});

test('parse method - custom version', () {
final version = FlutterVersion.parse('custom_3.6.0@huawei');
expect(version.name, 'custom_3.6.0@huawei');
expect(version.releaseFromChannel, isNull);
expect(version.type, VersionType.custom);
});

test('parse method - commit version', () {
final version = FlutterVersion.parse('f4c74a6ec3');
expect(version.name, 'f4c74a6ec3');
Expand Down Expand Up @@ -161,6 +175,12 @@ void main() {
expect(version.isCustom, isTrue);
});


test('isCustom getter', () {
final version = FlutterVersion.custom('custom_3.22.0@huawei');
expect(version.isCustom, isTrue);
});

test('printFriendlyName getter - channel version', () {
final version = FlutterVersion.channel('stable');
expect(version.printFriendlyName, 'Channel: Stable');
Expand Down