This commit is contained in:
dualfroz committed 2026-06-19 01:10:19 +02:00
1 parent d4fdc9890a
commit 5787b14880
22 files changed
+5766 -710

No files matched your search

+5 -3
View File
@@ -177,9 +177,11 @@ impl Provider for GiteaProvider {
.send().await?;
let v = Self::check(resp).await.context("repo_meta")?;
Ok(RepoMeta {
open_issues: v["open_issues_count"].as_u64().unwrap_or(0) as u32,
open_prs: v["open_pr_counter"].as_u64().unwrap_or(0) as u32,
stars: v["stars_count"].as_u64().unwrap_or(0) as u32,
open_issues: v["open_issues_count"].as_u64().unwrap_or(0) as u32,
open_prs: v["open_pr_counter"].as_u64().unwrap_or(0) as u32,
stars: v["stars_count"].as_u64().unwrap_or(0) as u32,
description: v["description"].as_str().filter(|s| !s.is_empty()).map(String::from),
topics: vec![],
})
}
+20 -2
View File
@@ -145,10 +145,19 @@ impl Provider for GitHubProvider {
0
};
let description = v["description"].as_str()
.filter(|s| !s.is_empty())
.map(|s| s.to_string());
let topics = v["topics"].as_array()
.map(|arr| arr.iter().filter_map(|t| t.as_str().map(String::from)).collect())
.unwrap_or_default();
Ok(RepoMeta {
open_issues: v["open_issues_count"].as_u64().unwrap_or(0) as u32,
open_issues: v["open_issues_count"].as_u64().unwrap_or(0) as u32,
open_prs,
stars: v["stargazers_count"].as_u64().unwrap_or(0) as u32,
stars: v["stargazers_count"].as_u64().unwrap_or(0) as u32,
description,
topics,
})
}
@@ -207,6 +216,15 @@ impl Provider for GitHubProvider {
Ok(())
}
async fn update_description(&self, repo: &str, description: &str) -> Result<()> {
let body = serde_json::json!({ "description": description });
let resp = self.client
.patch(self.url(&format!("repos/{}/{}", self.owner, repo)))
.json(&body).send().await?;
Self::check(resp).await.context("update_description")?;
Ok(())
}
async fn list_pull_requests(&self, repo: &str) -> Result<Vec<PrDetail>> {
let resp = self.client
.get(self.url(&format!("repos/{}/{}/pulls?state=open&per_page=100", self.owner, repo)))
+5 -3
View File
@@ -179,9 +179,11 @@ impl Provider for GitLabProvider {
.send().await?;
let v = Self::check(resp).await.context("repo_meta")?;
Ok(RepoMeta {
open_issues: v["open_issues_count"].as_u64().unwrap_or(0) as u32,
open_prs: v["merge_requests_count"].as_u64().unwrap_or(0) as u32,
stars: v["star_count"].as_u64().unwrap_or(0) as u32,
open_issues: v["open_issues_count"].as_u64().unwrap_or(0) as u32,
open_prs: v["merge_requests_count"].as_u64().unwrap_or(0) as u32,
stars: v["star_count"].as_u64().unwrap_or(0) as u32,
description: v["description"].as_str().filter(|s| !s.is_empty()).map(String::from),
topics: v["topics"].as_array().map(|a| a.iter().filter_map(|t| t.as_str().map(String::from)).collect()).unwrap_or_default(),
})
}
+11 -3
View File
@@ -27,9 +27,11 @@ pub struct PrInfo {
#[derive(Debug, Clone, Default)]
#[allow(dead_code)]
pub struct RepoMeta {
pub open_issues: u32,
pub open_prs: u32,
pub stars: u32,
pub open_issues: u32,
pub open_prs: u32,
pub stars: u32,
pub description: Option<String>,
pub topics: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
@@ -137,6 +139,12 @@ pub trait Provider: Send + Sync {
let _ = repo;
anyhow::bail!("archive_repo not supported by this provider")
}
/// Update the description of a repository.
async fn update_description(&self, repo: &str, description: &str) -> Result<()> {
let _ = (repo, description);
anyhow::bail!("update_description not supported by this provider")
}
}
/// Build a boxed `Provider` from an `Account`.