From bfdf6178f4dca2d492a9c514f8f7953d89bc1e1b Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Wed, 9 Jul 2025 21:16:37 -0600 Subject: [PATCH] add git::commit() --- src/git.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/git.rs b/src/git.rs index 087b13c..3374542 100644 --- a/src/git.rs +++ b/src/git.rs @@ -143,6 +143,19 @@ pub fn restore_file(file: &std::path::Path) -> Result<(), GitError> { return Ok(()); } +pub fn commit(dir: &std::path::Path, msg: &str) -> Result<(), GitError> { + let result = std::process::Command::new("git") + .args(["commit", "-m", msg]) + .current_dir(dir) + .output()?; + if !result.status.success() { + println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap()); + println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap()); + return Err(GitError::Oops); + } + Ok(()) +} + pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> { let mut git_dir = std::path::PathBuf::from(file); git_dir.pop();