summaryrefslogtreecommitdiffstats
path: root/src/prs.rs
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2024-05-31 19:06:07 +0200
committerCyborus <cyborus@cyborus.xyz>2024-06-04 04:16:19 +0200
commit98a82d04e7e3acc1c4970d08ca268acf36074ec6 (patch)
tree4dda7904f57150e9d4903a335992c2dbe1f7ad53 /src/prs.rs
parentMerge pull request 'pull request messages' (#72) from pr-message into main (diff)
downloadforgejo-cli-98a82d04e7e3acc1c4970d08ca268acf36074ec6.tar.xz
forgejo-cli-98a82d04e7e3acc1c4970d08ca268acf36074ec6.zip
update to `forgejo-api` v0.3.0
Diffstat (limited to '')
-rw-r--r--src/prs.rs13
1 files changed, 6 insertions, 7 deletions
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