atomcode_core/agent/
git_checkpoint.rs1use std::path::Path;
7use std::process::Command;
8
9pub fn create_checkpoint(working_dir: &Path) -> Option<String> {
11 let mut check_cmd = Command::new("git");
13 check_cmd.args(["rev-parse", "--git-dir"])
14 .current_dir(working_dir);
15 crate::process_utils::suppress_console_window_sync(&mut check_cmd);
16 let is_git = check_cmd
17 .output()
18 .ok()
19 .map(|o| o.status.success())
20 .unwrap_or(false);
21 if !is_git {
22 return None;
23 }
24
25 let mut stash_cmd = Command::new("git");
27 stash_cmd.args(["stash", "create"])
28 .current_dir(working_dir);
29 crate::process_utils::suppress_console_window_sync(&mut stash_cmd);
30 let output = stash_cmd.output().ok()?;
31
32 let sha = String::from_utf8_lossy(&output.stdout).trim().to_string();
33 if sha.is_empty() {
34 None
35 } else {
36 Some(sha)
37 }
38}