use serde::{Deserialize, Serialize};
use crate::clang_tools::Suggestion;
#[derive(Debug, Serialize)]
pub struct FullReview {
pub event: String,
pub body: String,
pub comments: Vec<ReviewDiffComment>,
}
#[derive(Debug, Serialize)]
pub struct ReviewDiffComment {
pub body: String,
pub line: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub start_line: Option<i64>,
pub path: String,
}
impl From<Suggestion> for ReviewDiffComment {
fn from(value: Suggestion) -> Self {
Self {
body: value.suggestion,
line: value.line_end as i64,
start_line: if value.line_end != value.line_start {
Some(value.line_start as i64)
} else {
None
},
path: value.path,
}
}
}
pub const REVIEW_DISMISSAL: &str = r#"{"event":"DISMISS","message":"outdated suggestion"}"#;
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct GithubChangedFile {
pub filename: String,
pub previous_filename: Option<String>,
pub patch: Option<String>,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct PushEventFiles {
pub files: Vec<GithubChangedFile>,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct PullRequestInfo {
pub draft: bool,
pub state: String,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct ReviewComment {
pub body: Option<String>,
pub id: i64,
pub state: String,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct ThreadComment {
pub id: i64,
pub body: String,
pub user: User,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct User {
pub login: String,
pub id: u64,
}