#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PrState {
Open,
Merged {
method: MergeMethod,
merge_commit: Option<String>,
},
Closed,
}
impl PrState {
pub fn is_merged(&self) -> bool {
matches!(self, PrState::Merged { .. })
}
pub fn is_open(&self) -> bool {
matches!(self, PrState::Open)
}
pub fn is_closed(&self) -> bool {
matches!(self, PrState::Closed)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MergeMethod {
Merge,
Squash,
Rebase,
}
impl std::fmt::Display for MergeMethod {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MergeMethod::Merge => write!(f, "merge"),
MergeMethod::Squash => write!(f, "squash"),
MergeMethod::Rebase => write!(f, "rebase"),
}
}
}
#[derive(Debug, Clone)]
pub struct PrInfo {
pub number: u64,
pub title: String,
pub url: String,
pub state: PrState,
pub base_branch: String,
}
impl PrInfo {
pub fn new(number: u64, title: &str, url: &str, state: PrState, base_branch: &str) -> Self {
Self {
number,
title: title.to_string(),
url: url.to_string(),
state,
base_branch: base_branch.to_string(),
}
}
}
#[derive(Debug, Clone)]
pub struct RawPrData {
pub number: u64,
pub title: String,
pub url: String,
pub state: String,
pub base_branch: String,
pub merge_commit: Option<String>,
}