Skip to content

fix: stop showing an update notice on the latest release - #382

Open
ch4-Zz wants to merge 1 commit into
achannarasappa:masterfrom
ch4-Zz:fix/update-notice-version-prefix
Open

fix: stop showing an update notice on the latest release#382
ch4-Zz wants to merge 1 commit into
achannarasappa:masterfrom
ch4-Zz:fix/update-notice-version-prefix

Conversation

@ch4-Zz

@ch4-Zz ch4-Zz commented Aug 25, 2026

Copy link
Copy Markdown

Problem

A release build always advertises an update, naming the version it is already running:

$ ticker --version
ticker version 5.3.0

and the UI shows v5.3.0 available.

Cause

newerVersion compares the raw strings:

if latest != currentVersion {
    return latest
}
  • latest comes from the GitHub API tag_name, so it keeps the leading v: v5.3.0.
  • currentVersion comes from cmd.Version, injected by .goreleaser.yml with
    -X 'github.com/achannarasappa/ticker/v5/cmd.Version={{.Version}}'. goreleaser expands
    {{.Version}} to the tag stripped of its v, so the binary reports 5.3.0.

"v5.3.0" != "5.3.0" is always true, so every release build shows the notice permanently,
and it survives the 3 hour cache because the cached value is compared the same way.

Reproducible from a released binary's own cache:

$ cat "$LOCALAPPDATA/cache/ticker/update-check.json"
{"checked_at":"2026-08-25T14:41:35+02:00","latest_version":"v5.3.0"}

Fix

Trim the leading v on both sides before comparing. This keeps the existing semantics
(report whenever the strings differ) and touches nothing else:

  • Dev builds are unaffected — Check still returns early on "v0.0.0" before reaching
    the comparison.
  • A genuinely newer release is still reported.

Why the tests missed it

updater_test.go uses currentVersion = "v5.0.0", with the prefix that release binaries
never have. Added two cases covering a release-shaped current version: one asserting no
notice when only the prefix differs, and one asserting a real update is still reported.

Alternative

If you would rather keep the comparison strict, the equivalent one-line fix is to inject
{{.Tag}} instead of {{.Version}} in .goreleaser.yml, so the binary version matches
both the tag and the v0.0.0 dev default. That changes what ticker --version prints
(v5.3.0 instead of 5.3.0), which is why I went with the updater side here. Happy to
switch if you prefer.

🤖 Generated with Claude Code

newerVersion compares the raw strings, so any difference reports an
update. The latest version comes from the GitHub API tag_name and keeps
its leading "v", while release binaries are built with
-X cmd.Version={{.Version}}, which goreleaser expands without that
prefix. On v5.3.0 the comparison is therefore "v5.3.0" != "5.3.0" and the
UI advertises the very version the user is already running, on every
release build.

Trim the prefix on both sides before comparing. Dev builds are unaffected:
Check still short-circuits on "v0.0.0" before reaching this comparison.

The existing tests missed this because they pass a current version that
keeps the "v", which release binaries never do.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant