From eb92038fbf4ae4cb9cca172350ef0e735572a879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Fri, 9 Jun 2023 14:48:42 +0200 Subject: [PATCH] Refactored GitRepo associated functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Strings representing where to run commands where one of: .current_dir(&(self.path.to_owned() + &self.name)) .current_dir(format!("{}{}", &self.path, &self.name)) Decided to change all instances to the latter, as asking people seemed to prefer it for readability. Signed-off-by: Christina Sørensen --- src/git.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/git.rs b/src/git.rs index 81b0b85..e8afa9f 100644 --- a/src/git.rs +++ b/src/git.rs @@ -98,7 +98,7 @@ impl GitRepo { /// Pulls the repository if able. fn pull(&self) { let out = Command::new("git") - .current_dir(&(self.path.to_owned() + &self.name)) + .current_dir(format!("{}{}", &self.path, &self.name)) .arg("pull") .status() .expect("failed to pull"); @@ -118,7 +118,7 @@ impl GitRepo { #[allow(dead_code)] fn commit(&self) { let out = Command::new("git") - .current_dir(&(self.path.to_owned() + &self.name)) + .current_dir(format!("{}{}", &self.path, &self.name)) .arg("commit") .status() .expect("failed to commit"); @@ -127,7 +127,7 @@ impl GitRepo { /// Tries to commit changes with a message argument. fn commit_with_msg(&self, msg: &String) { let out = Command::new("git") - .current_dir(&(self.path.to_owned() + &self.name)) + .current_dir(format!("{}{}", &self.path, &self.name)) .arg("commit") .arg("-m") .arg(msg) @@ -138,7 +138,7 @@ impl GitRepo { /// Attempts to push the repository. fn push(&self) { let out = Command::new("git") - .current_dir(&(self.path.to_owned() + &self.name)) + .current_dir(format!("{}{}", &self.path, &self.name)) .arg("push") .status() .expect("failed to push");