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
14
src/git.rs
14
src/git.rs
|
@ -117,6 +117,7 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
/// Adds all files in the repository.
|
/// Adds all files in the repository.
|
||||||
fn add_all(&self) {
|
fn add_all(&self) {
|
||||||
|
if self.push {
|
||||||
let out = Command::new("git")
|
let out = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("add")
|
.arg("add")
|
||||||
|
@ -124,19 +125,27 @@ impl GitRepo {
|
||||||
.status()
|
.status()
|
||||||
.unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,));
|
.unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,));
|
||||||
info!("{out}");
|
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) {
|
||||||
|
if self.push {
|
||||||
let out = Command::new("git")
|
let out = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("commit")
|
.arg("commit")
|
||||||
.status()
|
.status()
|
||||||
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
|
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
|
||||||
info!("{out}");
|
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) {
|
||||||
|
if self.push {
|
||||||
let out = Command::new("git")
|
let out = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("commit")
|
.arg("commit")
|
||||||
|
@ -145,6 +154,9 @@ impl GitRepo {
|
||||||
.status()
|
.status()
|
||||||
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
|
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
|
||||||
info!("{out}");
|
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