2022-08-20 07:06:55 +00:00
|
|
|
use crate::error;
|
|
|
|
|
2022-08-22 08:51:54 +00:00
|
|
|
use std::fs;
|
2022-08-20 07:06:55 +00:00
|
|
|
use std::path;
|
|
|
|
use std::process;
|
|
|
|
|
|
|
|
pub fn run_command(args : Vec<String>, vault_folder : &path::Path) -> Result<(), error::Error> {
|
|
|
|
|
|
|
|
let mut command = process::Command::new("git");
|
|
|
|
|
2022-08-20 23:58:05 +00:00
|
|
|
let mut child = command
|
2022-08-20 07:06:55 +00:00
|
|
|
.current_dir(vault_folder)
|
|
|
|
// Force colour output even though run from other process.
|
|
|
|
.args(["-c", "color.ui=always"])
|
2022-08-20 23:58:05 +00:00
|
|
|
.args(args)
|
|
|
|
.spawn()?;
|
2022-08-20 07:06:55 +00:00
|
|
|
|
2022-08-20 23:58:05 +00:00
|
|
|
// No point handling the potential error code as Git will report the error directly with more
|
|
|
|
// info.
|
|
|
|
let _ = child.wait()?;
|
2022-08-20 07:06:55 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-08-22 08:51:54 +00:00
|
|
|
|
|
|
|
pub fn create_gitignore(vault_folder : &path::Path) -> Result<(), error::Error> {
|
|
|
|
Ok(fs::write(vault_folder.join(".gitignore"), "state.toml\ntemp.toml\ntemp.md")?)
|
|
|
|
}
|