MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / run_commit

Method run_commit

claw-code/rust/crates/rusty-claude-cli/src/main.rs:1554–1590  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

1552 }
1553
1554 fn run_commit(&mut self) -> Result<(), Box<dyn std::error::Error>> {
1555 let status = git_output(&["status", "--short"])?;
1556 if status.trim().is_empty() {
1557 println!("Commit\n Result skipped\n Reason no workspace changes");
1558 return Ok(());
1559 }
1560
1561 git_status_ok(&["add", "-A"])?;
1562 let staged_stat = git_output(&["diff", "--cached", "--stat"])?;
1563 let prompt = format!(
1564 "Generate a git commit message in plain text Lore format only. Base it on this staged diff summary:\n\n{}\n\nRecent conversation context:\n{}",
1565 truncate_for_prompt(&staged_stat, 8_000),
1566 recent_user_context(self.runtime.session(), 6)
1567 );
1568 let message = sanitize_generated_message(&self.run_internal_prompt_text(&prompt, false)?);
1569 if message.trim().is_empty() {
1570 return Err("generated commit message was empty".into());
1571 }
1572
1573 let path = write_temp_text_file("claw-commit-message.txt", &message)?;
1574 let output = Command::new("git")
1575 .args(["commit", "--file"])
1576 .arg(&path)
1577 .current_dir(env::current_dir()?)
1578 .output()?;
1579 if !output.status.success() {
1580 let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
1581 return Err(format!("git commit failed: {stderr}").into());
1582 }
1583
1584 println!(
1585 "Commit\n Result created\n Message file {}\n\n{}",
1586 path.display(),
1587 message.trim()
1588 );
1589 Ok(())
1590 }
1591
1592 fn run_pr(&self, context: Option<&str>) -> Result<(), Box<dyn std::error::Error>> {
1593 let staged = git_output(&["diff", "--stat"])?;

Callers 1

handle_repl_commandMethod · 0.80

Calls 5

git_outputFunction · 0.85
git_status_okFunction · 0.85
write_temp_text_fileFunction · 0.85

Tested by

no test coverage detected