feat: directory moves — mirrored batch relocation of every indexed file under a dir

- MovePlan gains moves[] (file move = 1 relocation), left_behind[] for
  unindexable files that deliberately stay, prune_dirs[] applied after the
  batch (remove_dir only succeeds when empty, leftovers keep their home)
- plan::dir: nesting/target-exists guards, merged per-file rewrites
- apply: atomic N-rename batch (per-file git mv), rollback restores every
  move, rewrite and created dir newest-first
- mv_reject accepts dirs; --json adds moved_files/would_move_files only for
  real dir moves (single-file contract byte-identical); summary shows
  (N files) and left-behind count
- engine rollback/prune tests moved to tests/apply.rs (public API; a
  mid-batch failure cannot be forced through the CLI), java-rule e2e split
  into its own binary to keep every file under the 250-line budget
This commit is contained in:
loki5512344 2026-09-15 18:30:33 +02:00
parent b96deeaf2f
commit 6f7a2190e6
Signed by: boba
GPG key ID: 253067914055423B
17 changed files with 842 additions and 293 deletions

View file

@ -113,3 +113,21 @@ fn mv_no_git_keeps_the_plain_rename_unstaged() {
let target = git_output(tmp.path(), &["status", "--porcelain", "--", "utils/sum.ts"]);
assert!(target.starts_with("??"), "{target}");
}
#[test]
fn dir_move_stages_every_rename_and_prunes_the_source_dir() {
let tmp = git_fixture("basic");
jmove(&tmp, &["mv", "lib", "vendor/lib"])
.success()
.stdout(predicate::str::contains("(via git mv)"));
let staged = git_output(tmp.path(), &["diff", "--cached", "-M", "--name-status"]);
assert!(
staged.contains("vendor/lib/sum.ts") && staged.contains("lib/sum.ts"),
"{staged}"
);
assert!(tmp.path().join("vendor/lib/sum.ts").is_file());
assert!(
!tmp.path().join("lib").exists(),
"emptied source dir pruned"
);
}