fix: stop showing an update notice on the latest release - #382
Open
ch4-Zz wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A release build always advertises an update, naming the version it is already running:
and the UI shows
v5.3.0 available.Cause
newerVersioncompares the raw strings:latestcomes from the GitHub APItag_name, so it keeps the leadingv:v5.3.0.currentVersioncomes fromcmd.Version, injected by.goreleaser.ymlwith-X 'github.com/achannarasappa/ticker/v5/cmd.Version={{.Version}}'. goreleaser expands{{.Version}}to the tag stripped of itsv, so the binary reports5.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:
Fix
Trim the leading
von both sides before comparing. This keeps the existing semantics(report whenever the strings differ) and touches nothing else:
Checkstill returns early on"v0.0.0"before reachingthe comparison.
Why the tests missed it
updater_test.gousescurrentVersion = "v5.0.0", with the prefix that release binariesnever 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 matchesboth the tag and the
v0.0.0dev default. That changes whatticker --versionprints(
v5.3.0instead of5.3.0), which is why I went with the updater side here. Happy toswitch if you prefer.
🤖 Generated with Claude Code