fix: version check always prompts update even when already on latest#120
Conversation
Three root causes addressed:
1. Windows CRLF: qmake's $$system() embeds \r in APP_VERSION on Windows.
git describe returns "v0.0.53\r", Qt's toInt("53\r") = 0, so current
version parses as [0,0,0] - always older than any release.
Fix: Environnement::getVersion() now calls .trimmed().
2. Shallow clone: CI checkout with fetch-depth:1 means git describe can't
find tags, falls back to a bare commit hash like "8f6e749" which also
parses as [0,0,0].
Fix: Added fetch-depth: 0 to all checkout steps in every build/release
workflow.
3. git describe dirty suffix: "v0.0.53-3-gabcdef1" patch component fails
toInt(), also parses as 0.
Fix: PowerVelo.pro now strips \r, strips the "-N-gHASH" suffix via
$$section(), and validates the result starts with vX; falls back to
v0.0.0 for bare commit hashes.
Agent-Logs-Url: https://github.com/MaximumTrainer/MaximumTrainer_Redux/sessions/64d50ec9-ecc4-4c3d-9a7a-f5e87874ca71
Co-authored-by: MaximumTrainer <1376575+MaximumTrainer@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes the app always prompting “Update Available” by ensuring the embedded build version string is a clean, parseable vX.Y.Z and that CI checkouts include tag history so git describe resolves to a tag instead of a commit hash.
Changes:
- Trim CR/LF from
APP_VERSIONat runtime inEnvironnement::getVersion(). - Sanitize
git describeoutput inPowerVelo.pro(strip CR and-N-gHASHsuffix; fall back tov0.0.0when no tag is reachable). - Update GitHub Actions workflows to use
actions/checkoutwithfetch-depth: 0so tags are available.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/persistence/db/environnement.cpp | Trims embedded version string to avoid CR/LF breaking numeric parsing. |
| PowerVelo.pro | Normalizes git describe output before embedding as APP_VERSION. |
| .github/workflows/release-windows.yml | Ensures tag history is fetched for version embedding during Windows release builds. |
| .github/workflows/release-wasm.yml | Ensures tag history is fetched for version embedding during WASM release builds. |
| .github/workflows/release-mac.yml | Ensures tag history is fetched for version embedding during macOS release builds. |
| .github/workflows/release-linux.yml | Ensures tag history is fetched for version embedding during Linux release builds. |
| .github/workflows/build.yml | Ensures tag history is fetched for version embedding during CI builds. |
| .github/workflows/build-windows.yml | Ensures tag history is fetched for version embedding during Windows CI builds. |
| .github/workflows/build-mac.yml | Ensures tag history is fetched for version embedding during macOS CI builds. |
| .github/workflows/build-linux.yml | Ensures tag history is fetched for version embedding during Linux CI builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| GIT_VERSION = $$system(git describe --tags --match "v[0-9]*" --always) | ||
| # Strip any trailing carriage-return that qmake's $$system() may capture on | ||
| # Windows when git writes "\r\n" to stdout. | ||
| GIT_VERSION = $$replace(GIT_VERSION, \r, ) |
There was a problem hiding this comment.
In qmake .pro files, a single backslash typically escapes the next character, so \r may be needed for the regex engine to receive \r (carriage return). As written, $$replace(GIT_VERSION, \r, ) risks stripping literal 'r' characters instead of CR, leaving the Windows CRLF issue unresolved (and potentially corrupting tags that contain 'r'). Consider using $$replace(GIT_VERSION, \\r, ) or a character class like [\\r\\n] to reliably drop CR/LF from $$system() output.
| GIT_VERSION = $$replace(GIT_VERSION, \r, ) | |
| GIT_VERSION = $$replace(GIT_VERSION, \\r, ) |
|
@copilot apply changes based on the comments in this thread |
Single \r in a qmake .pro file is interpreted as literal backslash+'r', not a carriage-return. Use \\r so the regex engine receives \r (CR). Agent-Logs-Url: https://github.com/MaximumTrainer/MaximumTrainer_Redux/sessions/bd8f8b60-4c5b-4989-82e6-678bf7100764 Co-authored-by: MaximumTrainer <1376575+MaximumTrainer@users.noreply.github.com>
Fixed in ba6e905. Changed |
Every launch showed the "Update Available" dialog regardless of installed version because the current version always parsed as
[0, 0, 0], making it appear older than any release. Three compounding root causes:Root causes
qmake's$$system()embeds a trailing\rinAPP_VERSION.QString::toInt("53\r")returns 0 (strict Qt parsing), so"v0.0.53\r"→[0, 0, 0].fetch-depth: 1. Without tag history,git describefalls back to a bare commit hash ("8f6e749"), which also parses as[0, 0, 0]."v0.0.53-3-gabcdef1"; the"53-3-gabcdef1"patch component failstoInt()→ 0.Changes
src/persistence/db/environnement.cpp—getVersion()now calls.trimmed()to strip any embedded\r/\n.PowerVelo.pro— SanitisesGIT_VERSIONbefore embedding asAPP_VERSION:$$replace(GIT_VERSION, \\r, )— strips Windows CR (uses\\rso the regex engine receives the actual CR escape, not a literal 'r')$$section(GIT_VERSION, -, 0, 0)— drops-N-gHASHsuffix (mirrors existingNUMERIC_VERSIONlogic)!contains(GIT_VERSION, ^[vV][0-9])fallback to"v0.0.0"— catches bare commit hashes that slip through when no tag is reachableAll build/release workflows (8 files, 17 checkout steps) — Added
fetch-depth: 0sogit describe --tagscan always resolve the version tag.