#![allow(dead_code)]
use anyhow::Result;
use serde::{Deserialize, Serialize};
pub mod gitlab;
pub mod bitbucket;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum VCSProvider {
GitHub,
GitLab,
Bitbucket,
}
pub trait VCSClient: Send + Sync {
fn provider(&self) -> VCSProvider;
fn list_repositories(&self) -> impl std::future::Future<Output = Result<Vec<RepositoryInfo>>> + Send;
fn get_repository(&self, name: &str) -> impl std::future::Future<Output = Result<RepositoryInfo>> + Send;
fn list_branches(&self, repo: &str) -> impl std::future::Future<Output = Result<Vec<BranchInfo>>> + Send;
fn list_commits(&self, repo: &str, limit: usize) -> impl std::future::Future<Output = Result<Vec<CommitInfo>>> + Send;
fn get_pull_requests(&self, repo: &str) -> impl std::future::Future<Output = Result<Vec<PullRequestInfo>>> + Send;
fn get_languages(&self, repo: &str) -> impl std::future::Future<Output = Result<Vec<LanguageStats>>> + Send;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepositoryInfo {
pub name: String,
pub full_name: String,
pub description: Option<String>,
pub language: Option<String>,
pub stars: u32,
pub forks: u32,
pub is_private: bool,
pub default_branch: String,
pub url: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BranchInfo {
pub name: String,
pub sha: String,
pub is_default: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommitInfo {
pub sha: String,
pub message: String,
pub author: String,
pub date: String,
pub additions: i32,
pub deletions: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PullRequestInfo {
pub number: u32,
pub title: String,
pub state: String,
pub author: String,
pub created_at: String,
pub merged_at: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LanguageStats {
pub name: String,
pub bytes: u64,
pub percentage: f64,
}