forgejo-todo-checker/src/issues/fetch.rs
Paul Campbell b50f73b7b7
All checks were successful
Test / build (map[name:stable]) (push) Successful in 5m51s
Test / build (map[name:nightly]) (push) Successful in 5m2s
feat: add cli args to help run locally
2025-01-05 09:05:11 +00:00

28 lines
857 B
Rust

//
use std::collections::HashSet;
use crate::model::Config;
use color_eyre::{eyre::Context, Result};
use super::Issue;
pub async fn fetch_open_issues<'net, 'fs>(config: &Config<'net, 'fs>) -> Result<HashSet<Issue>> {
let server_url = config.server();
let repo = config.repo();
let url = format!("{server_url}/api/v1/repos/{repo}/issues?state=open");
println!("> {url}");
let net = config.net();
let response = net
.get(url)
.with_option(config.auth_token())
.some(|request, auth_token| request.header("Authorization", auth_token))
.send()
.await?;
println!("< {}", response.status());
let body = response.text().await.context("reading issues body")?;
let issues: HashSet<Issue> =
serde_json::from_str(&body).with_context(|| format!("body: {body}"))?;
Ok(issues)
}