use super::super::{context::*, errors::*, url::*, util::*};
use {
relative_path::*,
std::{fmt, sync::*},
};
#[derive(Clone, Debug)]
pub struct GitUrl {
pub repository_url: Arc<UrlRef>,
pub repository_gix_url: gix::Url,
pub path: RelativePathBuf,
pub(crate) context: UrlContextRef,
}
impl GitUrl {
pub fn parse(url_representation: &str) -> Result<(String, String), UrlError> {
parse_archive_entry_url_representation(url_representation, "git")
}
pub fn new(
context: &UrlContextRef,
repository_url: Arc<UrlRef>,
repository_gix_url: gix::Url,
path: RelativePathBuf,
) -> Self {
Self { repository_url, repository_gix_url, path, context: context.clone() }
}
pub fn new_with(&self, path: RelativePathBuf) -> Self {
Self::new(&self.context, self.repository_url.clone(), self.repository_gix_url.clone(), path)
}
}
impl fmt::Display for GitUrl {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "git:{}!{}", self.repository_url, self.path)
}
}
impl Into<UrlRef> for GitUrl {
fn into(self) -> UrlRef {
Box::new(self)
}
}