Compare commits

..

1 Commits

Author SHA1 Message Date
cuddle-please
5a792db905 chore(release): 0.2.0
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2024-09-13 17:55:10 +00:00
4 changed files with 31 additions and 64 deletions

View File

@ -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

View File

@ -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());
}

View File

@ -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"))]

View File

@ -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)
}
}