Files
gitnow/crates/gitnow/src/git_provider.rs
kjuulh 6a0900e190
All checks were successful
continuous-integration/drone/push Build is passing
feat: add github fetch prs refactoring
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-09-14 15:10:46 +02:00

34 lines
694 B
Rust

use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct Repository {
pub provider: String,
pub owner: String,
pub repo_name: String,
pub ssh_url: String,
}
impl Repository {
pub fn to_rel_path(&self) -> PathBuf {
PathBuf::from(&self.provider)
.join(&self.owner)
.join(&self.repo_name)
}
}
pub trait VecRepositoryExt {
fn collect_unique(&mut self) -> &mut Self;
}
impl VecRepositoryExt for Vec<Repository> {
fn collect_unique(&mut self) -> &mut Self {
self.sort_by_key(|a| a.to_rel_path());
self.dedup_by_key(|a| a.to_rel_path());
self
}
}
pub mod gitea;
pub mod github;