add git::commit()
This commit is contained in:
parent
16de030b8e
commit
bfdf6178f4
1 changed files with 13 additions and 0 deletions
13
src/git.rs
13
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue