use std::process::Command;
pub fn execute_git_command(args: &[String]) -> i32 {
let mut git_args = vec![
"-c".to_string(),
"color.status=always".to_string(),
"-c".to_string(),
"color.diff=always".to_string(),
"-c".to_string(),
"color.branch=always".to_string(),
"-c".to_string(),
"color.ui=always".to_string(),
];
git_args.extend_from_slice(args);
let status = Command::new("git")
.args(&git_args)
.status();
match status {
Ok(status) => status.code().unwrap_or(1),
Err(e) => {
eprintln!("Failed to execute git: {}", e);
1
}
}
}
pub fn exec_git_output(args: &[&str]) -> String {
let output = Command::new("git").args(args).output();
match output {
Ok(o) => String::from_utf8_lossy(&o.stdout).to_string(),
Err(e) => {
eprintln!("Failed to execute git: {}", e);
String::new()
}
}
}