Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

update: a build that says which build it is is still the release it is

Boris 'B' Kurktchiev76c3eaf6602a
diff --git a/frontend/src/lib/update.js b/frontend/src/lib/update.js
index 49457456e..370096a2d 100644
--- a/frontend/src/lib/update.js
+++ b/frontend/src/lib/update.js
@@ -13,10 +13,17 @@ const RELEASES_URL = `https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/re
/**
* Compares two semver strings (e.g. "1.2.11" vs "1.3.0").
* Returns 1 if a > b, -1 if a < b, 0 if equal.
+ *
+ * Build metadata is dropped first. A version that says which build it came from carries it as
+ * semver build metadata ("1.3.8+2026-09-18.2"), and splitting that on "." makes the patch NaN —
+ * which read as 0, so a release tagged that way compared as 1.3.0 and a real update went
+ * unnoticed. Semver says the metadata plays no part in precedence, so "1.3.7+anything" and
+ * "1.3.7" are the same version here. Dropped on both operands, so it holds whichever side
+ * carries it.
*/
function compareSemver(a, b) {
- const pa = a.replace(/^v/, '').split('.').map(Number)
- const pb = b.replace(/^v/, '').split('.').map(Number)
+ const pa = a.replace(/^v/, '').split('+')[0].split('.').map(Number)
+ const pb = b.replace(/^v/, '').split('+')[0].split('.').map(Number)
for (let i = 0; i < 3; i++) {
const diff = (pa[i] || 0) - (pb[i] || 0)
if (diff > 0) return 1
diff --git a/frontend/src/lib/update.test.js b/frontend/src/lib/update.test.js
index df8f20147..eabedb39a 100644
--- a/frontend/src/lib/update.test.js
+++ b/frontend/src/lib/update.test.js
@@ -265,6 +265,34 @@ describe('semver comparison (via checkForUpdate behavior)', () => {
expect((await checkForUpdate()).hasUpdate).toBe(true)
})
+ // A version may say which build it came from, as semver build metadata ("1.3.8+2026-09-18.2").
+ // It takes no part in precedence, and splitting it on "." used to make the patch NaN — which
+ // read as 0, so a tag carrying it compared as x.y.0 and a real update went unnoticed. Dropped
+ // on both operands, so the same holds whichever side carries it; here it is the tag, which is
+ // the side a test can reach (__APP_VERSION__ is a build-time define).
+ const BUILD = '+2026-09-18.2'
+ const [MAJOR, MINOR, PATCH_N] = __APP_VERSION__.split('+')[0].split('.').map(Number)
+ const tagged = (maj, min, patch) => 'v' + [maj, min, patch].join('.') + BUILD
+
+ it('judges a tag that carries build metadata on its numbers alone', async () => {
+ mockRelease(tagged(MAJOR, MINOR, PATCH_N + 1))
+ expect((await checkForUpdate()).hasUpdate).toBe(true)
+
+ resetUpdateCheck()
+ mockRelease(tagged(MAJOR, MINOR, PATCH_N))
+ const same = await checkForUpdate()
+ expect(same.hasUpdate).toBe(false) // the running release
+ expect(same.latestVersion).toBe(__APP_VERSION__.split('+')[0] + BUILD) // echoed as it came
+
+ resetUpdateCheck()
+ mockRelease(tagged(MAJOR, Math.max(0, MINOR - 1), 0))
+ expect((await checkForUpdate()).hasUpdate).toBe(false)
+
+ resetUpdateCheck()
+ mockRelease(tagged(MAJOR + 1, 0, 0))
+ expect((await checkForUpdate()).hasUpdate).toBe(true)
+ })
+
it('does not flag an older patch as an update', async () => {
// One patch below current (current patch is always >= our test floor)
mockRelease('v' + [MAJ, MIN, Math.max(0, PATCH - 1)].join('.'))