fix(offline): honor OFFLINE_WORK in git-ref2info and memoize TTL#9797
fix(offline): honor OFFLINE_WORK in git-ref2info and memoize TTL#9797iav wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds OFFLINE_WORK behavior: serve stale memoize cache when offline, use pinned SHAs from ChangesOffline Mode Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Test resultsStandalone scaffold (
All three guards exercised; |
88aabfd to
accc536
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/functions/general/git-ref2info.sh`:
- Around line 41-43: The offline_pinned assignment can produce multiple SHA
lines when git_sources.json has duplicate source+branch entries; change the jq
invocation in the offline_pinned assignment so it returns only a single match
(the first) for the given MEMO_DICT[GIT_SOURCE] and ref_name instead of multiple
lines (e.g., use jq’s first(...) or index [0] on the matching array) so the
subsequent 40-hex validation sees a single deterministic SHA for offline
resolution.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9fa27bd7-cd6a-4c46-ade3-b86004f8cfba
📒 Files selected for processing (2)
lib/functions/general/git-ref2info.shlib/functions/general/memoize-cached.sh
accc536 to
c4cabdc
Compare
Fixes #6439. memoized_git_ref_to_info() unconditionally ran 'git ls-remote' against the upstream source even with OFFLINE_WORK=yes; when the remote was unreachable the build aborted with a misleading network error. Two coordinated guards: * memoize-cached.sh: when OFFLINE_WORK=yes, serve the cache file regardless of TTL (alternative is a network call that will fail). The "stale cache served" event is logged. * git-ref2info.sh: early offline guard before the ls-remote loop. For ref_type=commit the SHA1 is taken from the ref itself (no network); for branch/tag we look up a pinned SHA1 in config/sources/git_sources.json. If neither is available, exit_with_error with a clear message instead of letting curl/ls-remote surface as 502. Same guard applied to the include_makefile_body block (curl to git host) since there is no local-bare fallback in scope here. Behaviour matrix unchanged for OFFLINE_WORK=no (default). Assisted-by: Claude:claude-opus-4.7
c4cabdc to
a7acb6f
Compare
|
@ColorfulRhino ping |
Summary
Fixes #6439.
memoized_git_ref_to_info()unconditionally rangit ls-remoteagainst the upstream source even withOFFLINE_WORK=yes; when the remote was unreachable (e.g.git.kernel.org502) the build aborted with a misleading network error instead of honoring the offline flag.Two coordinated guards:
memoize-cached.sh: whenOFFLINE_WORK=yes, serve the cache file regardless of TTL (the alternative is a network call that will fail). The "stale cache served" event is logged viadisplay_alert.git-ref2info.sh: early offline guard before thels-remoteloop. Forref_type=committhe SHA1 is taken from the ref itself (no network); for branch/tag we look up a pinned SHA1 inconfig/sources/git_sources.json. If neither is available,exit_with_errorwith a clear message instead of lettingcurl/ls-remotesurface as 502.The same guard is applied to the
include_makefile_bodyblock (curl to git host) since there is no local-bare fallback in scope here.Behaviour matrix unchanged for
OFFLINE_WORK=no(default).OFFLINE_WORKgit_sources.jsonls-remote(unchanged)ls-remotethen pinned override (unchanged)ls-remote(unchanged)Test plan
Verified via standalone scaffold against an isolated
${SRC}/cache/memoize/sandbox (see PR comment for full output):OFFLINE_WORK=yesbuild with prior populated cache → uses cache, no network callsOFFLINE_WORK=yesbuild with empty cache + no pinned SHA1 → fails with clear "OFFLINE_WORK=yes but no SHA1 available ... run online once or pin sha1" messageOFFLINE_WORK=yesbuild with empty cache + pinned inconfig/sources/git_sources.json→ uses pinned SHA1, no network callsOFFLINE_WORK=no(default) build → behaviour unchanged (onlinels-remotereturned real SHA1)OFFLINE_WORK=yeskernel-config (needs Makefile body) without cache → fails with clear "Makefile body ... not in cache" messageSummary by CodeRabbit
New Features
Bug Fixes