Skip to content

Extract updatecheck and improve sq version -v styling - #1235

Open
drluckyspin wants to merge 2 commits into
masterfrom
fix/improve-version-output
Open

drluckyspin wants to merge 2 commits into
masterfrom
fix/improve-version-output

Conversation

@drluckyspin

@drluckyspin drluckyspin commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Improve the visibility of availability of a new version for the user.

  • Extract Homebrew formula fetch, parse, and cache into cli/updatecheck (used only by sq version).
  • Add UpdateAvailable styling for newer releases in verbose sq version -v output.
  • No background network checks, interactive footer, or opt-out envar in this PR (follow-up on wip/update-footer-notices after design).
image

Follows maintainer feedback on #864: land the small extraction first, then rework the footer against an agreed state/control model.

Test plan

  • go test ./cli/updatecheck/... ./cli/output/tablew/...
  • go test ./cli/... -short
  • make lint
  • sq version -v on a machine with network (shows latest version styling when newer release exists)

Move Homebrew formula fetch and cache into cli/updatecheck for sq version
only. Highlight a newer release in verbose output with UpdateAvailable styling.
No background fetch or interactive footer yet.
@netlify

netlify Bot commented Sep 23, 2026

Copy link
Copy Markdown

Deploy Preview for sq-web canceled.

Name Link
🔨 Latest commit e36218d
🔍 Latest deploy log https://app.netlify.com/projects/sq-web/deploys/6ab345f0203c2c000837d291

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved cache correctness issues and incomplete styling coverage remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

This PR extracts Homebrew version checking into cli/updatecheck and highlights newer releases in verbose sq version output.

Changes:

  • Adds version fetching, parsing, caching, and normalization.
  • Adds UpdateAvailable styling and related tests.
  • Updates command integration and changelog documentation.

Review findings:

  • cli/updatecheck/updatecheck.gocritical, 1 vote: use unique temporary cache files to avoid concurrent refresh conflicts.
  • cli/updatecheck/updatecheck.gomoderate, 1 vote: enforce cache TTL when using offline fallback.
  • cli/updatecheck/updatecheck.gomoderate, 1 vote: avoid reading a relative cache file when caching is disabled.
  • cli/output/tablew/versionwriter_test.gomoderate, 1 vote: assert the latest-version value uses UpdateAvailable styling.
  • CHANGELOG.mdnit, 3 votes: correct the broken documentation link.
File Description
cli/​updatecheck/​updatecheck.go Implements version fetching and caching.
cli/​updatecheck/​updatecheck_test.go Tests parsing, normalization, and cache behavior.
cli/​output/​tablew/​versionwriter.go Applies styling to newer versions.
cli/​output/​tablew/​versionwriter_test.go Tests version styling.
cli/​output/​printing.go Adds update-available styling.
cli/​internal_test.go Removes obsolete test exports.
cli/​cmd_version.go Uses the new update-check package.
cli/​cmd_version_test.go Retains version command tests.
CHANGELOG.md Documents the update.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli/updatecheck/updatecheck.go Outdated
Comment thread CHANGELOG.md Outdated
Use CreateTemp for atomic cache writes, skip cache reads when cacheDir is
empty, honor TTL on offline fallback, fix CHANGELOG sq version URL, and
assert UpdateAvailable styling in the version writer test.
@drluckyspin

Copy link
Copy Markdown
Collaborator Author

Addressed Copilot review in e36218d:

  • Cache writes: writeCache now uses os.CreateTemp per refresh (no shared .tmp path).
  • Cache reads: skip when cacheDir is empty; offline fallback honors 24h TTL.
  • CHANGELOG: link corrected to sq.io/docs/cmd/version.
  • Test: color case asserts UpdateAvailable styling on the latest version value.

Tests and make lint pass locally.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

A moderate cache-validation issue remains unresolved.

Review effort: Lite
Findings: None

Resolved since last review (2)

@drluckyspin

Copy link
Copy Markdown
Collaborator Author

Design for the footer half of this work is tracked in #1237. This PR is the agreed first step (extraction + sq version -v styling only).

This branch has not been deployed

No deployments
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.

2 participants