@@ -86,7 +86,7 @@ pub async fn create_review(
8686 Some ( get_branch_names ( & ctx. legacy_project , & branch_id) ?)
8787 } else {
8888 // Find branches without PRs
89- let branches_without_prs = get_branches_without_prs ( & review_map, & applied_stacks) ;
89+ let branches_without_prs = get_branches_without_prs ( & review_map, & applied_stacks) ? ;
9090
9191 if branches_without_prs. is_empty ( ) {
9292 if let Some ( out) = out. for_human ( ) {
@@ -182,19 +182,25 @@ async fn ensure_forge_authentication(ctx: &mut Context) -> Result<(), anyhow::Er
182182fn get_branches_without_prs (
183183 review_map : & std:: collections:: HashMap < String , Vec < but_forge:: ForgeReview > > ,
184184 applied_stacks : & [ but_workspace:: legacy:: ui:: StackEntry ] ,
185- ) -> Vec < String > {
185+ ) -> anyhow :: Result < Vec < String > > {
186186 let mut branches_without_prs = Vec :: new ( ) ;
187187 for stack_entry in applied_stacks {
188188 for head in & stack_entry. heads {
189- let branch_name = head. name . to_string ( ) ;
190- if !review_map. contains_key ( & branch_name)
191- || review_map. get ( & branch_name) . map ( |v| v. is_empty ( ) ) . unwrap_or ( true )
189+ let branch_name = & head. name . to_string ( ) ;
190+ if !review_map. contains_key ( branch_name)
191+ || review_map. get ( branch_name) . map ( |v| v. is_empty ( ) ) . unwrap_or ( true )
192192 {
193- branches_without_prs. push ( branch_name) ;
193+ // This means that there are no associated reviews that are open, but that doesn't mean that there are
194+ // no associated reviews.
195+ // Check whether there's an associated forge review.
196+ if head. review_id . is_none ( ) {
197+ // If there's no associated review, the append the branch
198+ branches_without_prs. push ( branch_name. to_owned ( ) ) ;
199+ }
194200 }
195201 }
196202 }
197- branches_without_prs
203+ Ok ( branches_without_prs)
198204}
199205
200206fn get_branch_names ( project : & Project , branch_id : & str ) -> anyhow:: Result < Vec < String > > {
@@ -789,7 +795,6 @@ pub fn get_review_map(
789795 cache_config : Option < but_forge:: CacheConfig > ,
790796) -> anyhow:: Result < std:: collections:: HashMap < String , Vec < but_forge:: ForgeReview > > > {
791797 let reviews = but_api:: legacy:: forge:: list_reviews ( ctx, cache_config) . unwrap_or_default ( ) ;
792-
793798 let branch_review_map = reviews
794799 . into_iter ( )
795800 . fold ( std:: collections:: HashMap :: new ( ) , |mut acc, r| {
0 commit comments