Fix updater prerelease handling
This commit is contained in:
parent
fca7ffda93
commit
c5c4d446f3
3 changed files with 13 additions and 9 deletions
|
@ -6,9 +6,10 @@ class GithubApi {
|
|||
static const baseUrl = "https://api.github.com";
|
||||
|
||||
static Future<String> getLatestTagName() async {
|
||||
final response = await http.get(Uri.parse("$baseUrl/repos/Nutcake/ReCon/releases/latest"));
|
||||
final response = await http.get(Uri.parse("$baseUrl/repos/Nutcake/ReCon/releases?per_page=1"));
|
||||
if (response.statusCode != 200) return "";
|
||||
final body = jsonDecode(response.body);
|
||||
return body["tag_name"] ?? "";
|
||||
final body = jsonDecode(response.body) as List;
|
||||
if (body.isEmpty) return "";
|
||||
return body.first["tag_name"] ?? "";
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
|
||||
class SemVer {
|
||||
static final RegExp _versionMatcher = RegExp(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$");
|
||||
static final RegExp _characterFilter = RegExp(r"[a-z]");
|
||||
static final RegExp _characterFilter = RegExp(r"^[a-zA-Z]+");
|
||||
final int major;
|
||||
final int minor;
|
||||
final int patch;
|
||||
final String? label;
|
||||
|
||||
SemVer({required this.major, required this.minor, required this.patch});
|
||||
SemVer({required this.major, required this.minor, required this.patch, this.label});
|
||||
|
||||
factory SemVer.fromString(String str) {
|
||||
str = str.replaceAll(_characterFilter, "");
|
||||
|
@ -19,6 +20,7 @@ class SemVer {
|
|||
major: int.parse(match.group(1)!),
|
||||
minor: int.parse(match.group(2) ?? "0"),
|
||||
patch: int.parse(match.group(3) ?? "0"),
|
||||
label: match.group(4),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -38,7 +40,7 @@ class SemVer {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "$major.$minor.$patch";
|
||||
return "$major.$minor.$patch${label == null ? "" : "-$label"}";
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -48,10 +50,11 @@ class SemVer {
|
|||
runtimeType == other.runtimeType &&
|
||||
major == other.major &&
|
||||
minor == other.minor &&
|
||||
patch == other.patch;
|
||||
patch == other.patch &&
|
||||
label == other.label;
|
||||
|
||||
@override
|
||||
int get hashCode => major.hashCode ^ minor.hashCode ^ patch.hashCode;
|
||||
int get hashCode => major.hashCode ^ minor.hashCode ^ patch.hashCode ^ label.hashCode;
|
||||
|
||||
bool operator >(SemVer other) {
|
||||
if (major > other.major || (major == other.major && minor > other.minor) || (major == other.major && minor == other.minor && patch > other.patch)) {
|
||||
|
|
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 0.9.1+1
|
||||
version: 0.9.2-beta+1
|
||||
|
||||
environment:
|
||||
sdk: '>=3.0.1'
|
||||
|
|
Loading…
Reference in a new issue