Compare commits
2 Commits
fbef5f34e7
...
5a792db905
Author | SHA1 | Date | |
---|---|---|---|
|
5a792db905 | ||
6ab02860b3 |
14
CHANGELOG.md
14
CHANGELOG.md
@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.2.0] - 2024-09-13
|
||||
|
||||
### Added
|
||||
- gitea able to pull repositories
|
||||
- add config
|
||||
|
||||
### Docs
|
||||
- add readme
|
||||
|
||||
### Other
|
||||
- separate files
|
||||
- move config out
|
||||
- remove unused libraries
|
||||
|
||||
## [0.1.0] - 2024-09-12
|
||||
|
||||
### Added
|
||||
|
@ -3,7 +3,7 @@ members = ["crates/*"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
gitnow = { path = "crates/gitnow" }
|
||||
|
@ -17,5 +17,5 @@ uuid = { version = "1.7.0", features = ["v4"] }
|
||||
async-trait = "0.1.82"
|
||||
toml = "0.8.19"
|
||||
|
||||
gitea-rs = { git = "https://git.front.kjuulh.io/kjuulh/gitea-rs", ref = "main", version = "1.22.1" }
|
||||
gitea-rs = { git = "https://git.front.kjuulh.io/kjuulh/gitea-rs", version = "1.22.1" }
|
||||
url = "2.5.2"
|
||||
|
12
crates/gitnow/src/app.rs
Normal file
12
crates/gitnow/src/app.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use crate::config::Config;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct App {
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub async fn new_static(config: Config) -> anyhow::Result<&'static App> {
|
||||
Ok(Box::leak(Box::new(App { config })))
|
||||
}
|
||||
}
|
1
crates/gitnow/src/commands.rs
Normal file
1
crates/gitnow/src/commands.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod root;
|
62
crates/gitnow/src/commands/root.rs
Normal file
62
crates/gitnow/src/commands/root.rs
Normal file
@ -0,0 +1,62 @@
|
||||
use crate::{
|
||||
app::App,
|
||||
git_provider::{
|
||||
gitea::GiteaProviderApp, github::GitHubProviderApp, GitProvider, VecRepositoryExt,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RootCommand {
|
||||
app: &'static App,
|
||||
}
|
||||
|
||||
impl RootCommand {
|
||||
pub fn new(app: &'static App) -> Self {
|
||||
Self { app }
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub async fn execute(&mut self) -> anyhow::Result<()> {
|
||||
tracing::debug!("executing");
|
||||
|
||||
//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());
|
||||
}
|
||||
|
||||
tracing::info!("amount of repos fetched {}", repositories.len());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
@ -5,6 +5,8 @@ use clap::{Parser, Subcommand};
|
||||
use commands::root::RootCommand;
|
||||
use config::Config;
|
||||
|
||||
mod app;
|
||||
mod commands;
|
||||
mod config;
|
||||
mod git_provider;
|
||||
|
||||
@ -50,85 +52,3 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
mod app {
|
||||
use crate::config::Config;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct App {
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub async fn new_static(config: Config) -> anyhow::Result<&'static App> {
|
||||
Ok(Box::leak(Box::new(App { config })))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod commands {
|
||||
pub mod root {
|
||||
use crate::{
|
||||
app::App,
|
||||
git_provider::{
|
||||
gitea::GiteaProviderApp, github::GitHubProviderApp, GitProvider, VecRepositoryExt,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RootCommand {
|
||||
app: &'static App,
|
||||
}
|
||||
|
||||
impl RootCommand {
|
||||
pub fn new(app: &'static App) -> Self {
|
||||
Self { app }
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub async fn execute(&mut self) -> anyhow::Result<()> {
|
||||
tracing::debug!("executing");
|
||||
|
||||
//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());
|
||||
}
|
||||
|
||||
tracing::info!("amount of repos fetched {}", repositories.len());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user