Execute the move command. # Process 1. Find and open the repository 2. Normalize source and destination paths 3. Check that source is tracked 4. If not dry-run: a. Update tracking (move_file in repository) b. Move the actual file on disk 5. Display results
(&self)
| 209 | /// b. Move the actual file on disk |
| 210 | /// 5. Display results |
| 211 | fn run(&self) -> CliResult<()> { |
| 212 | // Route through the daemon when reachable (plain form only — the |
| 213 | // wire carries no dry-run/force); the local path is unchanged. |
| 214 | if crate::commands::rpc::mv(self)? { |
| 215 | return Ok(()); |
| 216 | } |
| 217 | |
| 218 | // Find repository |
| 219 | let repo_root = find_repository_root()?; |
| 220 | let repo = Repository::open(&repo_root).map_err(CliError::Repository)?; |
| 221 | let working_copy = repo |
| 222 | .require_working_copy_id() |
| 223 | .map_err(CliError::Repository)?; |
| 224 | |
| 225 | // Normalize paths |
| 226 | let source = self.normalize_path(&repo_root, &self.source)?; |
| 227 | let dest_raw = self.normalize_path(&repo_root, &self.destination)?; |
| 228 | let destination = self.resolve_destination(&repo_root, &source, &dest_raw); |
| 229 | |
| 230 | // Check if source exists and is tracked |
| 231 | if !repo.is_tracked(&source).map_err(CliError::Repository)? { |
| 232 | return Err(CliError::FileNotTracked { |
| 233 | path: PathBuf::from(&source), |
| 234 | }); |
| 235 | } |
| 236 | |
| 237 | // Check if source file exists on disk |
| 238 | let source_path = repo_root.join(&source); |
| 239 | if !source_path.exists() { |
| 240 | return Err(CliError::FileNotFound { path: source_path }); |
| 241 | } |
| 242 | |
| 243 | if source_path.is_dir() { |
| 244 | return Err(CliError::InvalidArgument { |
| 245 | message: "directory moves are not yet supported; move tracked files individually" |
| 246 | .to_string(), |
| 247 | }); |
| 248 | } |
| 249 | |
| 250 | // Never overwrite another tracked identity, even with --force. For an |
| 251 | // untracked filesystem destination, require --force before rename(2) |
| 252 | // can replace its bytes on platforms where that is the default. |
| 253 | if repo |
| 254 | .is_tracked(&destination) |
| 255 | .map_err(CliError::Repository)? |
| 256 | { |
| 257 | return Err(CliError::FileAlreadyTracked { |
| 258 | path: PathBuf::from(&destination), |
| 259 | }); |
| 260 | } |
| 261 | let destination_path = repo_root.join(&destination); |
| 262 | let destination_metadata = std::fs::symlink_metadata(&destination_path).ok(); |
| 263 | if destination_metadata.is_some() && !self.force { |
| 264 | return Err(CliError::InvalidArgument { |
| 265 | message: format!( |
| 266 | "destination '{}' already exists; use --force only for untracked content", |
| 267 | destination |
| 268 | ), |
nothing calls this directly
no test coverage detected