Files
weichen ac8db54ecb Add svc.sh update command: auto-detect repo advances and refresh services
Why:
After the repository moves forward, updating a running service meant
manually figuring out the new commit, rebuilding and redeploying by hand;
the user asked for the tool to detect and update automatically.

Evidence:
- "update [name...] [--check] [--all] [--no-fetch]": fetches origin,
  compares each service's registered source against the latest (Dev repo
  origin/main for local@/dev@ sources, newest Releases version for
  release@), prints a per-service table (current / latest / state), and
  without --check refreshes outdated running services by reusing the full
  deploy pipeline (stop → build/verify → start → health check; persisted
  exec= config and tags survive; update events appended to history).
- local@ services: auto git pull --ff-only origin main + make sync before
  rebuilding, guarded three ways (current branch == main, clean worktree,
  ff-only) — dirty trees or non-main branches are skipped with a warning,
  never touching uncommitted work.
- dev@ sources go straight to the remote main commit via an isolated
  worktree; release@ sources deploy the newest Releases version with
  sha256 verification; postgres and static --dir services are reported as
  not applicable; sources that diverged from or lead the remote are never
  force-updated.
- Verified end to end with five test services: dev@73b2802 → dev@ffda6d3
  (real isolated build, HTTP 200, tag/port preserved, worktree recycled),
  non-main-branch skip, stopped-service warning vs --all, release
  sha256-verified update, --check read-only (svc.env checksums unchanged),
  unregistered name exits 2.
- Fixed en route: a latent bug from the v2 refactor — materialize_dev_commit
  leaked submodule/make stdout into the captured worktree path, breaking
  every real dev@sha deploy since (cp: File name too long); build output
  now goes to stderr. Also fixed an unbound-variable crash in the update
  loop (local statement self-reference under set -u).

Impact:
New read-mostly operational command; no behavior change to existing
commands except dev@sha deploys now actually working end to end.
Makefile gains svc-update; --help and docs/svc.md document the command.

Refs: .task/feature-svc-auto-update.md(任务卡=PR 描述)
2026-09-30 15:22:33 +00:00
..