Fix wfctl falsely reporting older GitHub release as a newer version#328
Fix wfctl falsely reporting older GitHub release as a newer version#328
Conversation
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes wfctl update checks that incorrectly reported an older GitHub release as “available” when the locally installed version is newer, by comparing versions using semantic version ordering.
Changes:
- Add
isNewerVersion(latestVer, currentVer string) boolusinggolang.org/x/mod/semverfor strict semver comparison. - Update
checkForUpdateNoticeandrunUpdateto useisNewerVersioninstead of string inequality. - Add regression/unit tests covering the “older release suppressed” scenarios and semver comparison behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/wfctl/update.go | Switch update/notice logic to semver-based “latest > current” comparisons via a new helper. |
| cmd/wfctl/update_test.go | Add unit/regression tests for isNewerVersion, notice suppression, and runUpdate behavior when current is newer. |
cmd/wfctl/update_test.go
Outdated
| r, w, _ := os.Pipe() | ||
| os.Stderr = w | ||
|
|
||
| done := checkForUpdateNotice() | ||
| <-done | ||
|
|
||
| w.Close() | ||
| var buf [512]byte | ||
| n, _ := r.Read(buf[:]) | ||
| os.Stderr = origStderr |
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Fixed in d34fb69: |
checkForUpdateNoticeandrunUpdatecompared versions with string inequality (latest != current), causing a newer locally-installed version to be told an older GitHub release is "available".Changes
isNewerVersion(latestVer, currentVer string) bool— new helper usinggolang.org/x/mod/semver(already a transitive dep) for strict semver ordering; handles optionalvprefix and invalid inputscheckForUpdateNotice— replacelatest != currentwithisNewerVersion(latest, current)so the notice only fires when the release is genuinely newerrunUpdate— both the--checkreporting path and the install path now useisNewerVersion, so running a pre-release or ahead-of-latest build no longer triggers a spurious downgrade prompt📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.