INNER CODE UNIT · Rust

handle_commit_slash_command

0xKarl-dev/claw-codes · rust/crates/commands/src/lib.rs:784

pub fn handle_commit_slash_command(message: &str, cwd: &Path) -> io::Result<String> {
    let status = git_stdout(cwd, &["status", "--short"])?;
    if status.trim().is_empty() {
        return Ok(
            "Commit\n  Result           skipped\n  Reason           no workspace changes"
                .to_string(),
        );
    }

    let message = message.trim();
    if message.is_empty() {
        return Err(io::Error::other("generated commit message was empty"));
    }

    git_status_ok(cwd, &["add", "-A"])?;
    let path = write_temp_text_file("claw-commit-message", "txt", message)?;
    let path_string = path.to_string_lossy().into_owned();
    git_status_ok(cwd, &["commit", "--file", path_string.as_str()])?;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…