28 lines
857 B
Rust
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)
|
|
}
|