From d17f14be97f7906469b6960bd1400636263d39c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Thu, 20 Jul 2023 16:57:30 +0200 Subject: [PATCH] refactor(git): started implementing validity check for repo kinds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christina Sørensen --- src/git.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/git.rs b/src/git.rs index 8e1eb38..0dae95f 100644 --- a/src/git.rs +++ b/src/git.rs @@ -315,6 +315,44 @@ impl Repo { unimplemented!("This seems to easy to missuse/exploit"); // fs::remove_dir_all(format!("{}{}", &self.path, &self.name)) } + fn check_is_valid_GitRepo(&self) -> bool { + todo!(); + } + fn check_is_valid_GitHubRepo(&self) -> bool { + todo!(); + } + fn check_is_valid_GitLabRepo(&self) -> bool { + todo!(); + } + fn check_is_valid_GiteaRepo(&self) -> bool { + todo!(); + } + fn check_is_valid_UrlRepo(&self) -> bool { + todo!(); + } + fn check_is_valid_Link(&self) -> bool { + todo!(); + } + /// Check if Repo is a valid instance of its kind + pub fn is_valid_kind(&self) -> bool { + use RepoKinds::*; + match &self.kind { + Some(GitRepo) => self.check_is_valid_GitRepo(), + Some(GitHubRepo) => self.check_is_valid_GitHubRepo(), + Some(GitLabRepo) => self.check_is_valid_GitLabRepo(), + Some(GiteaRepo) => self.check_is_valid_GiteaRepo(), + Some(UrlRepo) => self.check_is_valid_UrlRepo(), + Some(Link) => self.check_is_valid_Link(), + Some(kind) => { + panic!("kind {kind:?} not implemented"); + false + } + None => { + println!("unknown kind {:?}", self.kind); + false + } + } + } } // pub fn all_on_all(&self, closures: Vec, break_on_err: bool) {