securegit 0.8.5

Zero-trust git replacement with 12 built-in security scanners, LLM redteam bridge, universal undo, durable backups, and a 50-tool MCP server
Documentation
use anyhow::{bail, Result};
use std::path::Path;

pub fn execute(path: &Path, source: &str, destination: &str) -> Result<()> {
    let repo = crate::ops::open_repo(path)?;

    let src_full = path.join(source);
    let dst_full = path.join(destination);

    if !src_full.exists() {
        bail!("bad source, source={}, destination={}", source, destination);
    }

    if dst_full.exists() {
        bail!(
            "destination exists, source={}, destination={}",
            source,
            destination
        );
    }

    // Create parent directory if needed
    if let Some(parent) = dst_full.parent() {
        if !parent.exists() {
            std::fs::create_dir_all(parent)?;
        }
    }

    std::fs::rename(&src_full, &dst_full)?;

    let mut index = repo.index()?;
    index.remove_path(Path::new(source))?;
    index.add_path(Path::new(destination))?;
    index.write()?;

    println!("Renamed {} -> {}", source, destination);
    Ok(())
}