Skip to content

fix: version check always prompts update even when already on latest#120

Merged
MaximumTrainer merged 3 commits intomasterfrom
copilot/fix-install-new-version-prompt
Apr 4, 2026
Merged

fix: version check always prompts update even when already on latest#120
MaximumTrainer merged 3 commits intomasterfrom
copilot/fix-install-new-version-prompt

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

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

  • Windows CRLFqmake's $$system() embeds a trailing \r in APP_VERSION. QString::toInt("53\r") returns 0 (strict Qt parsing), so "v0.0.53\r"[0, 0, 0].
  • Shallow CI clone — All checkout steps used default fetch-depth: 1. Without tag history, git describe falls back to a bare commit hash ("8f6e749"), which also parses as [0, 0, 0].
  • git-describe dirty suffix — Dev builds produce "v0.0.53-3-gabcdef1"; the "53-3-gabcdef1" patch component fails toInt() → 0.

Changes

  • src/persistence/db/environnement.cppgetVersion() now calls .trimmed() to strip any embedded \r/\n.
// Before
return QString(APP_VERSION);

// After
return QString(APP_VERSION).trimmed();
  • PowerVelo.pro — Sanitises GIT_VERSION before embedding as APP_VERSION:

    1. $$replace(GIT_VERSION, \\r, ) — strips Windows CR (uses \\r so the regex engine receives the actual CR escape, not a literal 'r')
    2. $$section(GIT_VERSION, -, 0, 0) — drops -N-gHASH suffix (mirrors existing NUMERIC_VERSION logic)
    3. !contains(GIT_VERSION, ^[vV][0-9]) fallback to "v0.0.0" — catches bare commit hashes that slip through when no tag is reachable
  • All build/release workflows (8 files, 17 checkout steps) — Added fetch-depth: 0 so git describe --tags can always resolve the version tag.

Copilot AI linked an issue Apr 4, 2026 that may be closed by this pull request
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>
Copilot AI changed the title [WIP] Fix endless prompts for new version installation fix: version check always prompts update even when already on latest Apr 4, 2026
Copilot AI requested a review from MaximumTrainer April 4, 2026 14:36
@MaximumTrainer MaximumTrainer requested review from Copilot and removed request for MaximumTrainer April 4, 2026 14:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_VERSION at runtime in Environnement::getVersion().
  • Sanitize git describe output in PowerVelo.pro (strip CR and -N-gHASH suffix; fall back to v0.0.0 when no tag is reachable).
  • Update GitHub Actions workflows to use actions/checkout with fetch-depth: 0 so 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.

Comment thread PowerVelo.pro Outdated
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, )
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
GIT_VERSION = $$replace(GIT_VERSION, \r, )
GIT_VERSION = $$replace(GIT_VERSION, \\r, )

Copilot uses AI. Check for mistakes.
@MaximumTrainer
Copy link
Copy Markdown
Owner

@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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

@copilot apply changes based on the comments in this thread

Fixed in ba6e905. Changed \r to \\r in the $$replace() call — in qmake, a single backslash escapes the next character so \r was matching literal 'r', not CR. With \\r, the regex engine receives the actual carriage-return escape.

Copilot AI requested a review from MaximumTrainer April 4, 2026 14:55
@MaximumTrainer MaximumTrainer marked this pull request as ready for review April 4, 2026 15:08
@MaximumTrainer MaximumTrainer merged commit a316008 into master Apr 4, 2026
19 checks passed
@MaximumTrainer MaximumTrainer deleted the copilot/fix-install-new-version-prompt branch April 4, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install new version

3 participants