From eebf27d46f0babe58def15dd72a1cab459e4bb4d Mon Sep 17 00:00:00 2001 From: Cyborus Date: Sun, 17 Dec 2023 11:17:49 -0500 Subject: [PATCH] allow url as remote --- src/repo.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/repo.rs b/src/repo.rs index 80249b5..a3521a4 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -10,9 +10,9 @@ pub struct RepoInfo { } impl RepoInfo { - pub fn get_current(name: Option<&str>) -> eyre::Result { + pub fn get_current(remote: Option<&str>) -> eyre::Result { let repo = git2::Repository::open(".")?; - let url = get_remote(&repo, name)?; + let url = get_remote(&repo, remote)?; let mut path = url.path_segments().ok_or_else(|| eyre!("bad path"))?; let owner = path @@ -50,6 +50,11 @@ impl RepoInfo { } fn get_remote(repo: &git2::Repository, name: Option<&str>) -> eyre::Result { + if let Some(name) = name { + if let Ok(url) = Url::parse(name) { + return Ok(url); + } + } let remote_name; let remote_name = match name { Some(name) => name,