diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-05-31 19:06:07 +0200 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-06-04 04:16:19 +0200 |
commit | 98a82d04e7e3acc1c4970d08ca268acf36074ec6 (patch) | |
tree | 4dda7904f57150e9d4903a335992c2dbe1f7ad53 /src/prs.rs | |
parent | Merge pull request 'pull request messages' (#72) from pr-message into main (diff) | |
download | forgejo-cli-98a82d04e7e3acc1c4970d08ca268acf36074ec6.tar.xz forgejo-cli-98a82d04e7e3acc1c4970d08ca268acf36074ec6.zip |
update to `forgejo-api` v0.3.0
Diffstat (limited to '')
-rw-r--r-- | src/prs.rs | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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 |