| 47 | } |
| 48 | |
| 49 | pub fn parse_git_remote(remote: &str) -> Result<GitRemote> { |
| 50 | let captures = REMOTE_REGEX.captures(remote).ok_or_else(|| { |
| 51 | anyhow!("Could not extract owner and repository from remote url: {remote}") |
| 52 | })?; |
| 53 | |
| 54 | let domain = captures.name("domain").unwrap().as_str(); |
| 55 | let owner = captures.name("owner").unwrap().as_str(); |
| 56 | let repository = captures.name("repository").unwrap().as_str(); |
| 57 | |
| 58 | Ok(GitRemote { |
| 59 | domain: domain.to_string(), |
| 60 | owner: owner.to_string(), |
| 61 | repository: repository.to_string(), |
| 62 | }) |
| 63 | } |
| 64 | |
| 65 | #[cfg(test)] |
| 66 | mod tests { |