1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
crate::newtype!(RemoteUrl: git_url_parse::GitUrl, derive_more::Display: "The URL of a remote repository");
impl RemoteUrl {
    pub fn parse(url: impl Into<String>) -> Option<Self> {
        Some(Self::new(::git_url_parse::GitUrl::parse(&url.into()).ok()?))
    }
}
impl TryFrom<gix::Url> for RemoteUrl {
    type Error = ();

    fn try_from(url: gix::Url) -> Result<Self, Self::Error> {
        let pass = url.password().map(|p| p.to_owned());
        let mut parsed = ::git_url_parse::GitUrl::parse(&url.to_string()).map_err(|_| ())?;
        parsed.token = pass;
        Ok(Self(parsed))
    }
}
impl RemoteUrl {
    pub fn matches(&self, other: &Self) -> bool {
        tracing::debug!(host = ?self.host, fullname = ?self.fullname, token = ?self.token, "a");
        tracing::debug!(host = ?other.host,  fullname = ?other.fullname, token = ?other.token,"b");
        self.host.eq(&other.host)
            && self.fullname.eq(&other.fullname)
            && self.token.eq(&other.token)
    }
}