Skip to content

feat(shared): offline-tolerant sync.sh#43

Merged
jr200 merged 1 commit into
masterfrom
feat/sync-offline-tolerant
Apr 22, 2026
Merged

feat(shared): offline-tolerant sync.sh#43
jr200 merged 1 commit into
masterfrom
feat/sync-offline-tolerant

Conversation

@jr200

@jr200 jr200 commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • sync.sh never blocks commits on network failure
  • New `SYNC_OFFLINE=1` env var to explicitly skip (airplane mode)
  • Per-file curl failures warn + skip; manifest fetch failure exits 0 cleanly
  • Atomic writes via `.tmp` + mv so cached copies aren't clobbered mid-fetch
  • `--max-time 10` on every curl

Why

Previous sync.sh used `set -euo pipefail` + `die()` on any curl failure, so an offline pre-commit run blocked the commit. Now: network down → warn + exit 0, committed files already in repo stay intact, cached files in `.shared/` stay as last-known-good.

Follow-up

Consumer repos' pre-commit `entry:` bootstrap (which curls sync.sh itself before it's cached) also needs offline-tolerance wrapping — separate PRs per consumer.

Test plan

  • normal online run: all files synced
  • `SYNC_OFFLINE=1 ./sync.sh python`: skipped cleanly
  • simulated offline (block network): exits 0, cached files preserved

sync.sh now never blocks commits on network failure:

- SYNC_OFFLINE=1 env var → skip entirely with warning, exit 0
- curl fetch failures → warn to stderr, skip that file, exit 0
- missing curl/jq → warn + exit 0 (local dev without deps still commits)
- unknown language → warn + exit 0 (no more hard die)
- committed files: write to .tmp first, atomically mv on success, preserving
  cached copy if fetch fails mid-run
- --max-time 10 on every curl so a hung network doesn't stall the hook

Committed files stay committed (release-please-config.json must live at repo
root for release-please-action to read it in CI); cached files stay in
.shared/ as before. Offline tolerance is purely about hook robustness — CI
still re-fetches on every run so canonical drift is picked up.

Consumers' pre-commit entry bootstrap will be updated in a follow-up to
tolerate the initial curl (before .shared/sync.sh is cached).
@jr200 jr200 merged commit e2caf77 into master Apr 22, 2026
2 checks passed
@jr200 jr200 deleted the feat/sync-offline-tolerant branch April 22, 2026 00:54
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