From 98a82d04e7e3acc1c4970d08ca268acf36074ec6 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Fri, 31 May 2024 13:06:07 -0400 Subject: [PATCH] update to `forgejo-api` v0.3.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/prs.rs | 13 ++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6a9b06..2743117 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -337,9 +337,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "forgejo-api" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0452961a1435fdf127da1a1ba13cb840efe26bf6169bfd8d6dafecdd3e0eafa" +checksum = "c9938546bc436425957b6365e204972f5e5a8c0318aed9e7e0f60a5eb5630f0c" dependencies = [ "base64ct", "bytes", diff --git a/Cargo.toml b/Cargo.toml index d62c8dc..ca36436 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ auth-git2 = "0.5.3" clap = { version = "4.3.11", features = ["derive"] } directories = "5.0.1" eyre = "0.6.8" -forgejo-api = "0.2.0" +forgejo-api = "0.3.0" futures = "0.3.28" git2 = "0.17.2" open = "5.0.0" diff --git a/src/prs.rs b/src/prs.rs index e4504e7..bd9852f 100644 --- a/src/prs.rs +++ b/src/prs.rs @@ -5,7 +5,7 @@ use eyre::OptionExt; use forgejo_api::{ structs::{ CreatePullRequestOption, MergePullRequestOption, RepoGetPullRequestCommitsQuery, - RepoGetPullRequestFilesQuery, + RepoGetPullRequestFilesQuery, StateType, }, Forgejo, }; @@ -429,14 +429,13 @@ pub async fn view_pr(repo: &RepoName, api: &Forgejo, id: u64) -> eyre::Result<() }; let state = pr .state - .as_deref() .ok_or_else(|| eyre::eyre!("pr does not have state"))?; + let is_merged = pr.merged.unwrap_or_default(); let state = match state { - "open" if is_draft => format!("{light_grey}Draft{reset}"), - "open" => format!("{bright_green}Open{reset}"), - "closed" if pr.merged.unwrap_or_default() => format!("{bright_magenta}Merged{reset}"), - "closed" => format!("{bright_red}Closed{reset}"), - _ => "Unknown".to_owned(), + StateType::Open if is_draft => format!("{light_grey}Draft{reset}"), + StateType::Open => format!("{bright_green}Open{reset}"), + StateType::Closed if is_merged => format!("{bright_magenta}Merged{reset}"), + StateType::Closed => format!("{bright_red}Closed{reset}"), }; let base = pr.base.as_ref().ok_or_eyre("pr does not have base")?; let base_repo = base