Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Sonnet 5.5 committed 2026-11-23 01:08:53 +00:00
1 parent dccbfd7d86
commit 17f81c60c8
20 files changed
+636 -447

No files matched your search

+10 -11
View File
@@ -7,8 +7,7 @@
/// versionCode. The latest-release API names the download URLs of both assets.
///|
pub let release_api : String =
"https://git.site.latha.org/api/v1/repos/experiments/launcher/releases/latest"
pub let release_api : String = "https://git.site.latha.org/api/v1/repos/experiments/launcher/releases/latest"
///|
pub let apk_asset : String = "ultra-launcher.apk"
@@ -45,12 +44,12 @@ pub fn parse_release(text : String) -> Release? {
}
}
}
Some({ tag: @jsonx.str(json, "tag_name"), version_url, apk_url })
Some({ tag: @jsonx.str(json, "tag_name"), version_url, apk_url, })
}
///|
/// The versionCode in a `version.json`.
pub fn parse_version(text : String) -> Int? {
pub fn parse_version(text : String) -> Int32? {
guard @jsonx.parse(text) is Some(json) else { return None }
match @jsonx.get(json, "versionCode") {
Some(Number(n, ..)) => Some(n.to_int())
@@ -60,7 +59,7 @@ pub fn parse_version(text : String) -> Int? {
///|
/// The versionCode a release tag `build-<N>` stands for.
pub fn tag_version(tag : String) -> Int? {
pub fn tag_version(tag : String) -> Int32? {
guard tag.has_prefix("build-") else { return None }
let rest = tag.clamped_view(start=6)
if rest.length() == 0 {
@@ -79,20 +78,20 @@ pub fn tag_version(tag : String) -> Int? {
///|
#derive(Eq, Debug)
pub(all) enum Decision {
UpToDate(Int)
UpToDate(Int32)
/// A newer build exists and should be installed.
Install(Int)
Install(Int32)
/// The user already cancelled this build's install; not offered again unless they ask.
Declined(Int)
Declined(Int32)
}
///|
/// `latest` is the newest published versionCode, `installed` the running one, `declined`
/// the last build whose install the user cancelled (-1: none).
pub fn decide(
latest : Int,
installed : Int,
declined : Int,
latest : Int32,
installed : Int32,
declined : Int32,
manual~ : Bool,
) -> Decision {
if latest <= installed {
+7 -2
View File
@@ -21,7 +21,10 @@ test "bad or partial release json" {
///|
test "version.json" {
assert_eq(parse_version("{\"versionCode\": 29000123, \"commit\": \"abc\"}"), Some(29000123))
assert_eq(
parse_version("{\"versionCode\": 29000123, \"commit\": \"abc\"}"),
Some(29000123),
)
assert_eq(parse_version("{}"), None)
assert_eq(parse_version("x"), None)
}
@@ -32,7 +35,9 @@ test "tags compare as build numbers" {
assert_eq(tag_version("build-"), None)
assert_eq(tag_version("v1.2.3"), None)
assert_eq(tag_version("build-12x"), None)
assert_true(tag_version("build-10").unwrap() < tag_version("build-9000").unwrap())
assert_true(
tag_version("build-10").unwrap() < tag_version("build-9000").unwrap(),
)
}
///|