1
0
Fork 0

fix: null team reviews

This commit is contained in:
Cyborus 2024-07-08 22:22:39 -04:00
parent e6339d7c4f
commit 03c2ff9a17
No known key found for this signature in database
6 changed files with 145 additions and 3 deletions

View file

@ -2034,6 +2034,7 @@ pub struct PullRequest {
#[serde(deserialize_with = "crate::none_if_blank_url")]
pub patch_url: Option<url::Url>,
pub pin_order: Option<u64>,
#[serde(deserialize_with = "crate::requested_reviewers_ignore_null")]
pub requested_reviewers: Option<Vec<User>>,
pub state: Option<StateType>,
pub title: Option<String>,

View file

@ -358,6 +358,18 @@ where
.or(Ok(None))
}
fn requested_reviewers_ignore_null<'de, D, DE>(
deserializer: D,
) -> Result<Option<Vec<structs::User>>, DE>
where
D: Deserializer<'de>,
DE: serde::de::Error,
{
let list: Option<Vec<Option<structs::User>>> =
Option::deserialize(deserializer).map_err(DE::custom)?;
Ok(list.map(|list| list.into_iter().filter_map(|x| x).collect::<Vec<_>>()))
}
fn parse_ssh_url(raw_url: &String) -> Result<Url, url::ParseError> {
// in case of a non-standard ssh-port (not 22), the ssh url coming from the forgejo API
// is actually parseable by the url crate, so try to do that first