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:
@@ -121,3 +121,42 @@ seed_minimal_config() {
|
||||
[[ "$stderr" == *"alias for --mode=adopt"* ]]
|
||||
[[ "$stderr" == *"conflicting"* ]]
|
||||
}
|
||||
|
||||
# ─── rename flag parsing & dispatch ─────────────────────────────────
|
||||
# Dispatch-layer only, like the rest of this file — anything requiring git
|
||||
# activity is covered by tests/unit/rename_e2e.bats.
|
||||
|
||||
@test "rename with no target exits non-zero and prints usage" {
|
||||
seed_minimal_config
|
||||
run --separate-stderr "$JOSH_BIN" rename
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$stderr" == *"Usage: josh-sync rename"* ]]
|
||||
}
|
||||
|
||||
@test "rename with none of --name/--subfolder/--subrepo-url dies with a clear message" {
|
||||
seed_minimal_config
|
||||
run --separate-stderr "$JOSH_BIN" rename example
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$stderr" == *"At least one of --name, --subfolder, or --subrepo-url is required"* ]]
|
||||
}
|
||||
|
||||
@test "rename against an unknown target dies with not-found, before any git/network activity" {
|
||||
seed_minimal_config
|
||||
run --separate-stderr "$JOSH_BIN" rename nonexistent --name renamed
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$stderr" == *"not found"* ]]
|
||||
}
|
||||
|
||||
@test "rename --name (no value) fails with a helpful message instead of crashing on unbound \$2" {
|
||||
seed_minimal_config
|
||||
run --separate-stderr "$JOSH_BIN" rename example --name
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$stderr" == *"--name requires a value"* ]]
|
||||
}
|
||||
|
||||
@test "--help advertises the rename command and its flags" {
|
||||
run --separate-stderr "$JOSH_BIN" --help
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$stderr" == *"rename <target>"* ]]
|
||||
[[ "$stderr" == *"--subrepo-url URL"* ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user