diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2023-12-17 17:20:34 +0100 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2023-12-17 17:20:34 +0100 |
commit | f57dceb1894acd5a531519068254ff9a08063512 (patch) | |
tree | c76c2e5659dadfca95b9faaa4e97ca3d6c33b621 | |
parent | Merge pull request 'do apt update' (#22) from mingw-gcc into main (diff) | |
parent | allow url as remote (diff) | |
download | forgejo-cli-f57dceb1894acd5a531519068254ff9a08063512.tar.xz forgejo-cli-f57dceb1894acd5a531519068254ff9a08063512.zip |
Merge pull request 'allow url as remote' (#23) from url-remote into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/23
-rw-r--r-- | src/repo.rs | 9 |
1 files 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<Self> { + pub fn get_current(remote: Option<&str>) -> eyre::Result<Self> { 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<Url> { + 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, |