summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2023-11-17 21:32:58 +0100
committerCyborus <cyborus@cyborus.xyz>2023-11-17 21:32:58 +0100
commit5999e1e0b58eb65dd6f3dec35de6ba06efc61147 (patch)
tree24960fbbaec4e494d50ef0bd603525ac1de1c681
parentfix url issues (diff)
downloadforgejo-cli-5999e1e0b58eb65dd6f3dec35de6ba06efc61147.tar.xz
forgejo-cli-5999e1e0b58eb65dd6f3dec35de6ba06efc61147.zip
format
-rw-r--r--src/main.rs5
-rw-r--r--src/repo.rs17
2 files changed, 8 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs
index 5008a92..cb8e8e9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -41,9 +41,7 @@ async fn main() -> eyre::Result<()> {
let host = host.map(|host| Url::parse(&host)).transpose()?;
let url = match host {
Some(url) => url,
- None => {
- repo::RepoInfo::get_current()?.url().clone()
- }
+ None => repo::RepoInfo::get_current()?.url().clone(),
};
let name = keys.get_login(&url)?.username();
eprintln!("currently signed in to {name}@{url}");
@@ -65,4 +63,3 @@ async fn readline(msg: &str) -> eyre::Result<String> {
})
.await?
}
-
diff --git a/src/repo.rs b/src/repo.rs
index a2cd210..4d0b572 100644
--- a/src/repo.rs
+++ b/src/repo.rs
@@ -1,7 +1,7 @@
use clap::Subcommand;
+use eyre::eyre;
use forgejo_api::CreateRepoOption;
use url::Url;
-use eyre::eyre;
pub struct RepoInfo {
owner: String,
@@ -14,9 +14,7 @@ impl RepoInfo {
let repo = git2::Repository::open(".")?;
let url = get_remote(&repo)?;
- 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
.next()
.ok_or_else(|| eyre!("path does not have owner name"))?
@@ -26,11 +24,7 @@ impl RepoInfo {
.ok_or_else(|| eyre!("path does not have repo name"))?;
let name = name.strip_suffix(".git").unwrap_or(name).to_string();
- let repo_info = RepoInfo {
- owner,
- name,
- url,
- };
+ let repo_info = RepoInfo { owner, name, url };
Ok(repo_info)
}
pub fn owner(&self) -> &str {
@@ -47,7 +41,10 @@ impl RepoInfo {
pub fn host_url(&self) -> Url {
let mut url = self.url.clone();
- url.path_segments_mut().expect("invalid url: cannot be a base").pop().pop();
+ url.path_segments_mut()
+ .expect("invalid url: cannot be a base")
+ .pop()
+ .pop();
url
}
}