From 7203a7309db220520cdfed9057b1b30b4fefd5e2 Mon Sep 17 00:00:00 2001 From: Thomas Eppers Date: Tue, 14 Sep 2021 16:46:07 +0200 Subject: [PATCH] removed unused warning --- src/repo.rs | 90 ++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/repo.rs b/src/repo.rs index 4bd8cc9..208b825 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -2,24 +2,24 @@ use std::fmt; use regex::Regex; -use crate::common; +// use crate::common; #[derive(Debug, PartialEq)] pub enum Error { - Conversion, - Empty, + // Conversion, + // Empty, NoTagFound, - InvalidChar, + // InvalidChar, MisformedInput, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Error::Conversion => write!(f, "Conversion error"), - Error::Empty => write!(f, "Input is empty"), + // Error::Conversion => write!(f, "Conversion error"), + // Error::Empty => write!(f, "Input is empty"), Error::NoTagFound => write!(f, "Expected a tag"), - Error::InvalidChar => write!(f, "Invalid character found"), + // Error::InvalidChar => write!(f, "Invalid character found"), Error::MisformedInput => write!(f, "Unexpected input"), } } @@ -67,13 +67,13 @@ pub fn split_tag_from_repo(input: &str) -> Result<(&str, &str), Error> { Ok((front, back)) } -pub fn split_repo(repo: &str) -> Result { - let split_tag: Vec<&str> = repo.split(":").collect(); - if split_tag.len() == 2 && split_tag[0].len() != 0 && split_tag[1].len() != 0 { - // - } - Ok(Repo::Project("".into())) -} +// pub fn split_repo(repo: &str) -> Result { +// let split_tag: Vec<&str> = repo.split(":").collect(); +// if split_tag.len() == 2 && split_tag[0].len() != 0 && split_tag[1].len() != 0 { +// // +// } +// Ok(Repo::Project("".into())) +// } pub fn split_repo_without_tag(repo: &str) -> Result { let repo = repo.trim(); @@ -117,26 +117,26 @@ pub fn split_tag(repo: &str) -> Result<(&str, &str), Error> { } } -pub fn extract(repo: &str) -> Result<(Option<&str>, Option<&str>, &str), Error> { - if repo.len() == 0 { - return Err(Error::Empty); - } - let regex = regex::Regex::new(r"([^/:]*?/)??([^/:]*?/)?([^/:]*):?(.*)?").unwrap(); - let caps = match regex.captures(repo) { - None => return Err(Error::Conversion), - Some(cap) => cap, - }; - let server = match caps.get(1) { - None => None, - Some(cap) => Some(common::remove_last_char(cap.as_str())), - }; - let orga = match caps.get(2) { - None => None, - Some(cap) => Some(common::remove_last_char(cap.as_str())), - }; +// pub fn extract(repo: &str) -> Result<(Option<&str>, Option<&str>, &str), Error> { +// if repo.len() == 0 { +// return Err(Error::Empty); +// } +// let regex = regex::Regex::new(r"([^/:]*?/)??([^/:]*?/)?([^/:]*):?(.*)?").unwrap(); +// let caps = match regex.captures(repo) { +// None => return Err(Error::Conversion), +// Some(cap) => cap, +// }; +// let server = match caps.get(1) { +// None => None, +// Some(cap) => Some(common::remove_last_char(cap.as_str())), +// }; +// let orga = match caps.get(2) { +// None => None, +// Some(cap) => Some(common::remove_last_char(cap.as_str())), +// }; - Ok((server, orga, caps.get(3).unwrap().as_str())) -} +// Ok((server, orga, caps.get(3).unwrap().as_str())) +// } #[cfg(test)] mod tests { @@ -144,18 +144,18 @@ mod tests { use crate::repo::{Error, Repo}; // #[test] - fn test_repo_regex() { - assert_eq!(repo::extract(""), Err(repo::Error::Empty)); - assert_eq!( - repo::extract("ghcr.io/library/nginx"), - Ok((Some("ghcr.io"), Some("library"), "nginx")) - ); - assert_eq!( - repo::extract("library/nginx"), - Ok((None, Some("library"), "nginx")) - ); - assert_eq!(repo::extract("nginx"), Ok((None, None, "nginx"))); - } + // fn test_repo_regex() { + // assert_eq!(repo::extract(""), Err(repo::Error::Empty)); + // assert_eq!( + // repo::extract("ghcr.io/library/nginx"), + // Ok((Some("ghcr.io"), Some("library"), "nginx")) + // ); + // assert_eq!( + // repo::extract("library/nginx"), + // Ok((None, Some("library"), "nginx")) + // ); + // assert_eq!(repo::extract("nginx"), Ok((None, None, "nginx"))); + // } #[test] fn split_tag() {