fix(banner): invalidate update-check cache when local HEAD moves - #38337
Open
ssiweifnag wants to merge 1 commit into
Open
fix(banner): invalidate update-check cache when local HEAD moves#38337ssiweifnag wants to merge 1 commit into
ssiweifnag wants to merge 1 commit into
Conversation
The 6h update-check cache was keyed on (HERMES_REVISION, VERSION, ts). After a successful 'git pull' or rebase, neither of those changes but HEAD has moved, so the cache would keep returning the pre-pull 'behind' count for up to 6 hours — printing 'Update available: N commits behind' even when the local checkout is now caught up. Add the local short HEAD hash to both the cache write and the read invalidation condition so any local-history movement refreshes the count. For pip installs (no local HEAD) the value is None and behaves identically to before. Repo_dir is now resolved once at the top of the function instead of inside the if/else branch, which also flattens the embedded_rev / git / pypi dispatch into a single if/elif/else.
Collaborator
|
This is a duplicate of the long-running update-check cache invalidation chain — same root cause (cache keyed on |
Contributor
|
Thanks for targeting a real cache-invalidation gap. Current main still returns a fresh Problems
Suggested changes
Automated hermes-sweeper review. |
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
hermes_cli/banner.py:check_for_updates()writes a 6h cache file at~/.hermes/.update_checkand keys it on(HERMES_REVISION, VERSION, ts). None of those change after a successfulgit pull/rebase, so the cache survives for up to 6 hours andhermes --versionkeeps reporting the pre-pull "Update available: N commits behind" even when the local checkout is now caught up.Fix
Add the local short HEAD hash to both the cache write and the read-invalidation condition. For pip installs (no local HEAD) the value is
Noneand the cache key collapses back to the original(rev, ver)pair, preserving the #34491 fix.While moving the HEAD resolution out of the cache block, also flattened the embedded-rev / git / pypi dispatch into a single
if/elif/elsesorepo_diris resolved once at the top.Repro
The repro's "Update available: 38 commits behind" survives up to 6h today; with this patch it disappears the moment HEAD moves.
Test plan
tests/hermes_cli/test_cmd_update.py(25 cases) still passes — verified locally.behind=N, head=H1, run a no-op commit, runhermes --version, confirm cache file is rewritten (tsadvanced,headupdated to H2).headisnullin the cache and invalidation still works viarev/verchanges only.