mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-10 12:09:33 +01:00
Merge pull request 'allow url as remote' (#23) from url-remote into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/23
This commit is contained in:
commit
f57dceb189
1 changed files with 7 additions and 2 deletions
|
@ -10,9 +10,9 @@ pub struct RepoInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 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 mut path = url.path_segments().ok_or_else(|| eyre!("bad path"))?;
|
||||||
let owner = path
|
let owner = path
|
||||||
|
@ -50,6 +50,11 @@ impl RepoInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_remote(repo: &git2::Repository, name: Option<&str>) -> eyre::Result<Url> {
|
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;
|
||||||
let remote_name = match name {
|
let remote_name = match name {
|
||||||
Some(name) => name,
|
Some(name) => name,
|
||||||
|
|
Loading…
Reference in a new issue