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:
parent
c104bfca8f
commit
720b9b0de1
1 changed files with 34 additions and 22 deletions
56
src/git.rs
56
src/git.rs
|
@ -117,34 +117,46 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
/// Adds all files in the repository.
|
/// Adds all files in the repository.
|
||||||
fn add_all(&self) {
|
fn add_all(&self) {
|
||||||
let out = Command::new("git")
|
if self.push {
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
let out = Command::new("git")
|
||||||
.arg("add")
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg(".")
|
.arg("add")
|
||||||
.status()
|
.arg(".")
|
||||||
.unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,));
|
.status()
|
||||||
info!("{out}");
|
.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.
|
/// Tries to commit changes in the repository.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn commit(&self) {
|
fn commit(&self) {
|
||||||
let out = Command::new("git")
|
if self.push {
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
let out = Command::new("git")
|
||||||
.arg("commit")
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.status()
|
.arg("commit")
|
||||||
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
|
.status()
|
||||||
info!("{out}");
|
.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.
|
/// Tries to commit changes with a message argument.
|
||||||
fn commit_with_msg(&self, msg: &String) {
|
fn commit_with_msg(&self, msg: &String) {
|
||||||
let out = Command::new("git")
|
if self.push {
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
let out = Command::new("git")
|
||||||
.arg("commit")
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("-m")
|
.arg("commit")
|
||||||
.arg(msg)
|
.arg("-m")
|
||||||
.status()
|
.arg(msg)
|
||||||
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
|
.status()
|
||||||
info!("{out}");
|
.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.
|
/// Attempts to push the repository.
|
||||||
fn push(&self) {
|
fn push(&self) {
|
||||||
|
@ -163,7 +175,7 @@ impl GitRepo {
|
||||||
fn remove(&self) -> Result<(), std::io::Error> {
|
fn remove(&self) -> Result<(), std::io::Error> {
|
||||||
// https://doc.rust-lang.org/std/fs/fn.remove_dir_all.html
|
// https://doc.rust-lang.org/std/fs/fn.remove_dir_all.html
|
||||||
unimplemented!("This seems to easy to missuse/exploit");
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue