Skip to content

Fix: clear cmake cache when git HEAD is unavailable#865

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/treat-missing-git-head-as-stale-cache
May 27, 2026
Merged

Fix: clear cmake cache when git HEAD is unavailable#865
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/treat-missing-git-head-as-stale-cache

Conversation

@ChaoWao
Copy link
Copy Markdown
Collaborator

@ChaoWao ChaoWao commented May 27, 2026

Summary

  • _invalidate_cache_if_stale used to silently skip invalidation when git rev-parse HEAD returned nothing (no .git, transient subprocess failure), leaving stale objects in build/cache/.
  • It now wipes the cache directory and writes no marker — the next run also rebuilds — so an unreachable git always degrades to a clean compile rather than to undetected staleness.
  • Added unit tests in tests/ut/py/test_runtime_builder.py::TestInvalidateCacheIfStale covering all three branches (match / mismatch / unavailable).

Testing

  • python -m pytest tests/ut/py/test_runtime_builder.py — 21 passed, 4 hardware-skipped

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

_invalidate_cache_if_stale previously returned early when git rev-parse
could not produce a commit (no .git, transient subprocess failure),
leaving any old marker and build artifacts in place. That silently
defeats the invalidation guard whenever git is briefly unreachable.

Treat an unavailable HEAD as definitely-stale: wipe the cache dir and
do not write a marker, so the next build also rebuilds from scratch.
A clean compile is cheap relative to the risk of linking against
mismatched objects.
@ChaoWao ChaoWao force-pushed the fix/treat-missing-git-head-as-stale-cache branch from 0114264 to 2bb1682 Compare May 27, 2026 05:59
@ChaoWao ChaoWao merged commit 9f15e82 into hw-native-sys:main May 27, 2026
15 checks passed
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.

1 participant