fix(flutter): preserve dev-version safety net + update version tests

Two test failures from the comparator rewrite:

1. "different unparseable strings → newer" was useful — branch-name
   builds (e.g. PackageInfo reports 'main' while server reports
   'dev') should still surface the banner so the operator sees that
   something is misaligned. Restore that fallback: if both sides
   parse to all-zero components (no numeric structure on either),
   compare as strings.

2. "honors prerelease ordering" tested pub_semver behavior we no
   longer use. Replaced with tests that cover what the new
   comparator actually does: zero-padding for length mismatch,
   leading-zero normalization, 4-part date+build comparisons, and
   month-rollover correctness without leading zeros.
This commit is contained in:
2026-05-11 10:48:06 -04:00
parent a65474284a
commit 74cc76b369
2 changed files with 34 additions and 8 deletions
@@ -71,6 +71,18 @@ bool isVersionNewer(String serverVersion, String installedVersion) {
final svr = parts(serverVersion);
final ins = parts(installedVersion);
// Safety net for non-numeric versions (e.g. branch-name builds like
// "main" vs "dev"): if neither side parsed any non-zero component,
// fall back to string inequality so an operator on a dev build
// still gets the banner instead of silently matching everything.
final svrAllZero = svr.every((c) => c == 0);
final insAllZero = ins.every((c) => c == 0);
if (svrAllZero && insAllZero) {
return serverVersion.replaceFirst(RegExp(r'^v'), '') !=
installedVersion.replaceFirst(RegExp(r'^v'), '');
}
final n = svr.length > ins.length ? svr.length : ins.length;
while (svr.length < n) {
svr.add(0);