From 391128cba85ccf8341807d89a048c028b824890b Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Fri, 8 Nov 2024 17:01:31 +0100 Subject: [PATCH] bin: Fix broken review loading in `patch review` --- bin/cob/patch.rs | 9 +++------ bin/commands/patch.rs | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/bin/cob/patch.rs b/bin/cob/patch.rs index 5532abfe..d94ace26 100644 --- a/bin/cob/patch.rs +++ b/bin/cob/patch.rs @@ -90,14 +90,11 @@ pub fn find_review<'a, G: Signer>( patch: &'a Patch, revision: &Revision, signer: &G, -) -> Result> { - match patch +) -> Option<(ReviewId, &'a Review)> { + patch .reviews_of(revision.id()) .find(|(_, review)| review.author().public_key() == signer.public_key()) - { - Some((id, review)) => Ok(Some((id.clone(), review))), - None => anyhow::bail!("Could not find review by me"), - } + .map(|(id, review)| (id.clone(), review)) } #[cfg(test)] diff --git a/bin/commands/patch.rs b/bin/commands/patch.rs index 37c54538..2ffb510d 100644 --- a/bin/commands/patch.rs +++ b/bin/commands/patch.rs @@ -344,7 +344,7 @@ mod interface { return Ok(()); }; - if let Some((id, _)) = patch::find_review(&patch, revision, &signer)? { + if let Some((id, _)) = patch::find_review(&patch, revision, &signer) { // Review already started, resume. log::info!("Resuming review {id}.."); } else { @@ -365,8 +365,8 @@ mod interface { loop { // Reload review - let (review_id, review) = patch::find_review(&patch, revision, &signer)? - .ok_or_else(|| anyhow!("Could not load review by me"))?; + let (review_id, review) = patch::find_review(&patch, revision, &signer) + .ok_or_else(|| anyhow!("Could not find review."))?; log::info!( "Found comments for {review_id}: {:?}",