feat(josh-sync): add rename command for safe target renames
Adds `josh-sync rename <target>` (PE-12): safely rename a sync target's name, subfolder, and/or subrepo_url in one resumable operation, editing .josh-sync.yml and migrating its state-branch files atomically instead of orphaning them. Bumps josh-sync to v2.3.0. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TNXgcFWVgSh3wkQS55cCX6
This commit is contained in:
@@ -673,6 +673,29 @@ To add a new subrepo after initial setup:
|
||||
```
|
||||
5. Verify with `josh-sync status`
|
||||
|
||||
## Renaming a Target
|
||||
|
||||
Hand-editing `targets[].name`, `.subfolder`, or `.subrepo_url` in `.josh-sync.yml` orphans sync state — state on the `josh-sync-state` branch is keyed by target name, and a subfolder change leaves the stored `josh_filter` stale until reconciliation happens to catch it. `josh-sync rename <target>` does both the config edit and the state migration atomically:
|
||||
|
||||
```bash
|
||||
josh-sync rename billing --name payments # rename only
|
||||
josh-sync rename billing --subfolder services/payments # move + re-derive josh_filter
|
||||
josh-sync rename billing --subrepo-url git@host:ext/payments.git # point at a moved/renamed subrepo
|
||||
josh-sync rename billing --name payments --subfolder services/payments # combine in one call
|
||||
|
||||
josh-sync rename billing --name payments --dry-run # preview only, no writes
|
||||
josh-sync rename billing --name payments --yes # skip the confirmation prompt
|
||||
```
|
||||
|
||||
What it does, in order: resolves the target (and detects a resumed run if the config already shows the new name), validates the new name/URL, checks for recent sync activity on the target (best-effort concurrency heuristic — warns/aborts unless `--force`), refuses to proceed if state already exists under the new name (never forceable), edits `.josh-sync.yml` and re-validates it, then moves every file under `<target>/` on `josh-sync-state` to the new prefix in one commit.
|
||||
|
||||
**What it does NOT do:**
|
||||
- Rename or move the repository on the git host — do that first (Gitea/GitHub UI or API), then run `josh-sync rename` to update josh-sync's own bookkeeping.
|
||||
- Rename `auto-sync/mono-*`/`auto-sync/subrepo-*` conflict/staging branches — they never carry the target name, so there's nothing to rename. An abandoned onboarding's `auto-sync/import-<old-name>-*` branch (which does carry the name) is only flagged with a warning; merge or delete it manually.
|
||||
- Guarantee `.josh-sync.yml`'s comments survive byte-for-byte — the edit is a scoped `yq -i`, which may reflow surrounding formatting.
|
||||
|
||||
**Concurrency**: the heuristic checks for a `josh-sync-state` commit under the target within the last 5 minutes. It's best-effort — a sync that starts after the check but before rename's own push can still race. `--force` bypasses only this check; a destination-name conflict or unreachable new URL always hard-fails.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Failed to clone through josh-proxy"
|
||||
|
||||
Reference in New Issue
Block a user