Skip to content
Snippets Groups Projects
Commit 059914a2 authored by nfontrod's avatar nfontrod
Browse files

src/commit.rs: add delete_commit function

parent e7d8b678
Branches
No related tags found
Loading
...@@ -37,12 +37,33 @@ pub fn get_current_commit() -> String { ...@@ -37,12 +37,33 @@ pub fn get_current_commit() -> String {
commit commit
} }
/// function that deletes commit if needed
pub fn delete_commit(commit: &str, borg_path: &PathBuf) {
let output = Command::new("borg")
.arg("delete")
.arg(format!("{}::{}", borg_path.to_str().unwrap(), commit))
.output()
.unwrap();
match output.status.code().unwrap() {
0 => (),
num => {
eprintln!("{}", String::from_utf8(output.stderr).unwrap());
exit(num);
}
}
}
/// Create a commit of the results folder named as the current git commit id /// Create a commit of the results folder named as the current git commit id
pub fn commit(compression: String, mut commit: String) { pub fn commit(compression: String, mut commit: String, update: bool) {
let (borg_folder, results_folder) = check_path(); let (borg_folder, results_folder) = check_path();
if commit == String::from("") { if commit == String::from("") {
commit = get_current_commit(); commit = get_current_commit();
} }
if update {
delete_commit(&commit, &borg_folder);
}
let output = Command::new("borg") let output = Command::new("borg")
.arg("create") .arg("create")
.arg("--stats") .arg("--stats")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment