fix: remove potentially destructive operaton

Commented out code that could potentially be destructive, right now it's
only a sketch, and if the unimplemented macro was removed one might be
mistaken thinking the associated function was intended for use.

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-06-22 14:58:13 +02:00
parent c104bfca8f
commit 720b9b0de1
Signed by: cafkafk
GPG key ID: CDDC792F655251ED

View file

@ -117,34 +117,46 @@ impl GitRepo {
}
/// Adds all files in the repository.
fn add_all(&self) {
let out = Command::new("git")
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("add")
.arg(".")
.status()
.unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,));
info!("{out}");
if self.push {
let out = Command::new("git")
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("add")
.arg(".")
.status()
.unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,));
info!("{out}");
} else {
info!("{} has clone set to false, not cloned", &self.name);
}
}
/// Tries to commit changes in the repository.
#[allow(dead_code)]
fn commit(&self) {
let out = Command::new("git")
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("commit")
.status()
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
info!("{out}");
if self.push {
let out = Command::new("git")
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("commit")
.status()
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
info!("{out}");
} else {
info!("{} has clone set to false, not cloned", &self.name);
}
}
/// Tries to commit changes with a message argument.
fn commit_with_msg(&self, msg: &String) {
let out = Command::new("git")
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("commit")
.arg("-m")
.arg(msg)
.status()
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
info!("{out}");
if self.push {
let out = Command::new("git")
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("commit")
.arg("-m")
.arg(msg)
.status()
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
info!("{out}");
} else {
info!("{} has clone set to false, not cloned", &self.name);
}
}
/// Attempts to push the repository.
fn push(&self) {
@ -163,7 +175,7 @@ impl GitRepo {
fn remove(&self) -> Result<(), std::io::Error> {
// https://doc.rust-lang.org/std/fs/fn.remove_dir_all.html
unimplemented!("This seems to easy to missuse/exploit");
fs::remove_dir_all(format!("{}{}", &self.path, &self.name))
// fs::remove_dir_all(format!("{}{}", &self.path, &self.name))
}
}