move method

  1. @override
Future<void> move(
  1. String from,
  2. String to
)
override

Moves/renames from to to.

Implementation

@override
Future<void> move(String from, String to) async {
  final src = normalizeRepoPath(from);
  final dst = normalizeRepoPath(to);
  final content = _files.remove(src);
  if (content != null) {
    _files[dst] = content;
    return;
  }
  // Move a "directory": re-key everything under `src/` to `dst/`.
  final under = _files.keys.where((f) => f.startsWith('$src/')).toList();
  if (under.isEmpty) throw RepoException('Path not found: $from');
  for (final f in under) {
    _files['$dst${f.substring(src.length)}'] = _files.remove(f)!;
  }
}