refactor: improved GitRepo assoc. function debug

Made the GitRepo associated functions easier to debug, by providing
additional output of the struct when running the git command on the repo
fails.

Also removed commented out code in main.

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-06-18 19:37:55 +02:00
parent cab7f72e28
commit 5e974e213d
Signed by: cafkafk
GPG key ID: CDDC792F655251ED
2 changed files with 6 additions and 7 deletions

View file

@ -99,7 +99,7 @@ impl GitRepo {
.arg(&self.url)
.arg(&self.name)
.status()
.unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,));
.unwrap_or_else(|_| panic!("git repo failed to clone: {:?}", &self,));
info!("{out}");
} else {
info!("{} has clone set to false, not cloned", &self.name);
@ -121,7 +121,7 @@ impl GitRepo {
.arg("add")
.arg(".")
.status()
.expect("failed to add");
.unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,));
info!("{out}");
}
/// Tries to commit changes in the repository.
@ -131,7 +131,7 @@ impl GitRepo {
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("commit")
.status()
.expect("failed to commit");
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
info!("{out}");
}
/// Tries to commit changes with a message argument.
@ -142,7 +142,7 @@ impl GitRepo {
.arg("-m")
.arg(msg)
.status()
.expect("failed to commit");
.unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,));
info!("{out}");
}
/// Attempts to push the repository.
@ -151,7 +151,7 @@ impl GitRepo {
.current_dir(format!("{}{}", &self.path, &self.name))
.arg("push")
.status()
.expect("failed to push");
.unwrap_or_else(|_| panic!("git repo failed to push: {:?}", &self,));
info!("{out}");
}
/// Removes repository

View file

@ -76,7 +76,6 @@ mod config {
use std::env::current_dir;
use std::fs::File;
use std::io::prelude::*;
//use utils::dir::current_dir;
#[test]
fn init_config() {
let _config = Config {
@ -178,7 +177,7 @@ mod config {
}
}
/* Unable to test with networking inside flake
/* FIXME Unable to test with networking inside flake
#[cfg(test)]
mod repo_actions {
use crate::*;