Add automatic version check with cached notifications#89
Draft
jamesainslie wants to merge 8 commits into
Draft
Conversation
Design document for automatic update checking against the GitHub Releases API with cached results, one-time notifications per new version, and an explicit --check-update flag for full changelog display.
Check for new versions after target execution with cached results (24h TTL). Shows a one-liner notification once per new version, auto-disables in CI. Adds --check-update flag for explicit check with full changelog display. New package pkg/update/ with GitHub client, cache, and core logic. Configurable via update_check settings in stave.yaml and STAVE_NO_UPDATE_CHECK environment variable.
Without this, all CheckAndNotify tests silently pass in GitHub Actions because env.InCI() returns true and short-circuits before reaching the code under test.
W1: Consolidate CI detection — internal/hooks now delegates to env.InCI()
instead of maintaining a separate CI env var list with different semantics.
W2: Deduplicate CI env var lists — export env.CIEnvVarNames() as the
canonical source; both test files now consume it.
W3: Consistent error format — github.go status errors now use verb-phrase
prefix matching the pattern used by all other errors in the function.
W4: Thread io.Writer into changelogStyle() — uses *os.File type assertion
for terminal background detection instead of hardcoded os.Stdin/Stdout.
S1: Unexport DefaultUpdateCheckInterval — only used within config package.
S2: Unexport CachePath — only used within pkg/update.
S3: Wrap ExplicitCheck error with "checking for updates" context.
S5: Isolate cache subtests — each subtest gets its own temp directory.
S6: Document intentional unconditional update check after target execution.
testGitInit in both internal/hooks and pkg/stave now sets GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM to /dev/null via cmd.Env (compatible with t.Parallel) and writes a local core.hooksPath override so production code under test doesn't inherit the user's global hooks path. Also adds .worktrees/ to .gitignore so the markdown linter doesn't scan untracked worktree content, and removes the design doc from tracking per convention.
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.
Summary
Adds a post-execution version check that queries the GitHub Releases API and notifies users when a newer version of stave is available. Results are cached locally (default 24 hours) so the check doesn't add latency on every run. Once a user has been notified about a specific version, the notification is silenced until the next release.
stave --check-updatefetches fresh release data and renders the full changelog with styled terminal output (headings, bullet points, links).update_check.enabledandupdate_check.intervalinstave.yaml, plusSTAVE_NO_UPDATE_CHECK=1env var override.What changed
pkg/update/package: GitHub API client, JSON file cache, version comparison (semver), styled terminal notifications with glamour markdown rendering.pkg/env.InCI(): Canonical CI environment detection, replacing duplicated logic ininternal/hooks/runtime.go.config.UpdateCheckConfig: Enabled flag and check interval with viper/YAML support.pkg/stave/main.go:CheckUpdatefield onRunParams,--check-updatepseudo-flag, post-execution hook inRunCompiled().testGitInitin bothinternal/hooksandpkg/stavenow properly isolates from user git config (GIT_CONFIG_GLOBAL/SYSTEM + local core.hooksPath override).Test plan
pkg/update/(cache, GitHub client via httptest, auto-check suppression chain, explicit check, semver comparison)pkg/env/cmd/stave/