Compare commits
1 Commits
3ecc46ca94
...
5a792db905
Author | SHA1 | Date | |
---|---|---|---|
|
5a792db905 |
@ -16,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- add readme
|
||||
|
||||
### Other
|
||||
- move projects list into separate file
|
||||
- separate files
|
||||
- move config out
|
||||
- remove unused libraries
|
||||
|
@ -3,7 +3,6 @@ use crate::{
|
||||
git_provider::{
|
||||
gitea::GiteaProviderApp, github::GitHubProviderApp, GitProvider, VecRepositoryExt,
|
||||
},
|
||||
projects_list::ProjectsListApp,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -20,9 +19,38 @@ impl RootCommand {
|
||||
pub async fn execute(&mut self) -> anyhow::Result<()> {
|
||||
tracing::debug!("executing");
|
||||
|
||||
let repositories = self.app.projects_list().get_projects().await?;
|
||||
|
||||
//let github_provider = self.app.github_provider();
|
||||
let gitea_provider = self.app.gitea_provider();
|
||||
|
||||
let mut repositories = Vec::new();
|
||||
for gitea in self.app.config.providers.gitea.iter() {
|
||||
if let Some(user) = &gitea.current_user {
|
||||
let mut repos = gitea_provider
|
||||
.list_repositories_for_current_user(
|
||||
user,
|
||||
&gitea.url,
|
||||
gitea.access_token.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
repositories.append(&mut repos);
|
||||
}
|
||||
|
||||
for gitea_user in gitea.users.iter() {
|
||||
let mut repos = gitea_provider
|
||||
.list_repositories_for_user(
|
||||
gitea_user.into(),
|
||||
&gitea.url,
|
||||
gitea.access_token.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
repositories.append(&mut repos);
|
||||
}
|
||||
}
|
||||
|
||||
repositories.collect_unique();
|
||||
|
||||
for repo in &repositories {
|
||||
tracing::info!("repo: {}", repo.to_rel_path().display());
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ mod app;
|
||||
mod commands;
|
||||
mod config;
|
||||
mod git_provider;
|
||||
mod projects_list;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = Some("Navigate git projects at the speed of thought"))]
|
||||
|
@ -1,59 +0,0 @@
|
||||
use crate::{
|
||||
app::App,
|
||||
git_provider::{gitea::GiteaProviderApp, Repository, VecRepositoryExt},
|
||||
};
|
||||
|
||||
pub struct ProjectsList {
|
||||
app: &'static App,
|
||||
}
|
||||
|
||||
impl ProjectsList {
|
||||
pub fn new(app: &'static App) -> Self {
|
||||
Self { app }
|
||||
}
|
||||
|
||||
pub async fn get_projects(&self) -> anyhow::Result<Vec<Repository>> {
|
||||
let gitea_provider = self.app.gitea_provider();
|
||||
|
||||
let mut repositories = Vec::new();
|
||||
for gitea in self.app.config.providers.gitea.iter() {
|
||||
if let Some(user) = &gitea.current_user {
|
||||
let mut repos = gitea_provider
|
||||
.list_repositories_for_current_user(
|
||||
user,
|
||||
&gitea.url,
|
||||
gitea.access_token.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
repositories.append(&mut repos);
|
||||
}
|
||||
|
||||
for gitea_user in gitea.users.iter() {
|
||||
let mut repos = gitea_provider
|
||||
.list_repositories_for_user(
|
||||
gitea_user.into(),
|
||||
&gitea.url,
|
||||
gitea.access_token.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
repositories.append(&mut repos);
|
||||
}
|
||||
}
|
||||
|
||||
repositories.collect_unique();
|
||||
|
||||
Ok(repositories)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ProjectsListApp {
|
||||
fn projects_list(&self) -> ProjectsList;
|
||||
}
|
||||
|
||||
impl ProjectsListApp for &'static App {
|
||||
fn projects_list(&self) -> ProjectsList {
|
||||
ProjectsList::new(self)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user