@@ -744,14 +744,35 @@ fn proposal_review_summary_markdown(
744744 md_content. push_str ( & format ! ( "Vote: {}\n " , proposal_review. vote) ) ;
745745 md_content. push_str ( & format ! (
746746 "Hashes match: {}\n " ,
747- proposal_review. build_reproduced. unwrap_or( false )
747+ proposal_review
748+ . build_reproduced
749+ . map( |b| b. to_string( ) )
750+ . unwrap_or( "Unanswered" . to_string( ) )
748751 ) ) ;
749752 md_content. push_str ( & format ! (
750753 "All reviewed commits match their descriptions: {}\n " ,
751- reviewed_commits. iter( ) . all( |( _, commit) | commit
752- . reviewed_state( )
753- . and_then( |state| state. matches_description)
754- . unwrap_or( false ) )
754+ {
755+ let mut no_answer_commits_count = 0 ;
756+ let mut all_reviewed_commits_match = true ;
757+
758+ for ( _, commit) in & reviewed_commits {
759+ let state = commit. reviewed_state( ) . expect( "should be reviewed" ) ;
760+ match state. matches_description {
761+ None => no_answer_commits_count += 1 ,
762+ Some ( b) => {
763+ all_reviewed_commits_match = b;
764+ }
765+ }
766+ }
767+
768+ if no_answer_commits_count == reviewed_commits. len( ) {
769+ "Unanswered" . to_string( )
770+ } else if no_answer_commits_count > 0 {
771+ "Only partially answered (see individual reports below)" . to_string( )
772+ } else {
773+ all_reviewed_commits_match. to_string( )
774+ }
775+ } ,
755776 ) ) ;
756777 }
757778 // images
@@ -2493,7 +2514,7 @@ mod tests {
24932514 }
24942515
24952516 #[ fixture]
2496- fn reviewed_commits ( ) -> Vec < ( ProposalReviewCommitId , ProposalReviewCommit ) > {
2517+ fn all_reviewed_commits_match ( ) -> Vec < ( ProposalReviewCommitId , ProposalReviewCommit ) > {
24972518 vec ! [
24982519 (
24992520 fixtures:: uuid( ) ,
@@ -2530,6 +2551,82 @@ mod tests {
25302551 ]
25312552 }
25322553
2554+ #[ fixture]
2555+ fn all_reviewed_commits_not_answered ( ) -> Vec < ( ProposalReviewCommitId , ProposalReviewCommit ) > {
2556+ vec ! [
2557+ (
2558+ fixtures:: uuid( ) ,
2559+ ProposalReviewCommit {
2560+ commit_sha: fixtures:: commit_sha_a( ) ,
2561+ state: ReviewCommitState :: Reviewed ( ReviewedCommitState {
2562+ matches_description: None ,
2563+ comment: Some ( "Good commit" . to_string( ) ) ,
2564+ highlights: vec![ "Feature A" . to_string( ) , "Bug fix B" . to_string( ) ] ,
2565+ } ) ,
2566+ ..fixtures:: proposal_review_commit_reviewed( )
2567+ } ,
2568+ ) ,
2569+ (
2570+ fixtures:: uuid( ) ,
2571+ ProposalReviewCommit {
2572+ commit_sha: fixtures:: commit_sha_b( ) ,
2573+ state: ReviewCommitState :: Reviewed ( ReviewedCommitState {
2574+ matches_description: None ,
2575+ comment: Some ( "Issues found" . to_string( ) ) ,
2576+ highlights: vec![ "Missing tests" . to_string( ) ] ,
2577+ } ) ,
2578+ ..fixtures:: proposal_review_commit_reviewed( )
2579+ } ,
2580+ ) ,
2581+ (
2582+ fixtures:: uuid( ) ,
2583+ ProposalReviewCommit {
2584+ commit_sha: fixtures:: commit_sha_c( ) ,
2585+ state: ReviewCommitState :: NotReviewed ,
2586+ ..fixtures:: proposal_review_commit_reviewed( )
2587+ } ,
2588+ ) ,
2589+ ]
2590+ }
2591+
2592+ #[ fixture]
2593+ fn some_reviewed_commits_not_answered ( ) -> Vec < ( ProposalReviewCommitId , ProposalReviewCommit ) > {
2594+ vec ! [
2595+ (
2596+ fixtures:: uuid( ) ,
2597+ ProposalReviewCommit {
2598+ commit_sha: fixtures:: commit_sha_a( ) ,
2599+ state: ReviewCommitState :: Reviewed ( ReviewedCommitState {
2600+ matches_description: Some ( true ) ,
2601+ comment: Some ( "Good commit" . to_string( ) ) ,
2602+ highlights: vec![ "Feature A" . to_string( ) , "Bug fix B" . to_string( ) ] ,
2603+ } ) ,
2604+ ..fixtures:: proposal_review_commit_reviewed( )
2605+ } ,
2606+ ) ,
2607+ (
2608+ fixtures:: uuid( ) ,
2609+ ProposalReviewCommit {
2610+ commit_sha: fixtures:: commit_sha_b( ) ,
2611+ state: ReviewCommitState :: Reviewed ( ReviewedCommitState {
2612+ matches_description: None ,
2613+ comment: Some ( "Issues found" . to_string( ) ) ,
2614+ highlights: vec![ "Missing tests" . to_string( ) ] ,
2615+ } ) ,
2616+ ..fixtures:: proposal_review_commit_reviewed( )
2617+ } ,
2618+ ) ,
2619+ (
2620+ fixtures:: uuid( ) ,
2621+ ProposalReviewCommit {
2622+ commit_sha: fixtures:: commit_sha_c( ) ,
2623+ state: ReviewCommitState :: NotReviewed ,
2624+ ..fixtures:: proposal_review_commit_reviewed( )
2625+ } ,
2626+ ) ,
2627+ ]
2628+ }
2629+
25332630 #[ fixture]
25342631 fn images_paths ( ) -> Vec < String > {
25352632 vec ! [
@@ -2541,23 +2638,27 @@ mod tests {
25412638 #[ rstest]
25422639 fn test_proposal_review_summary_markdown ( ) {
25432640 let basic_proposal = basic_proposal ( ) ;
2544- let basic_review = basic_review ( ) ;
2545- let reviewed_commits = reviewed_commits ( ) ;
2641+ let mut basic_review = basic_review ( ) ;
2642+ let mut review_commits = all_reviewed_commits_match ( ) ;
25462643 let images_paths = images_paths ( ) ;
25472644 let markdown = proposal_review_summary_markdown (
25482645 & basic_proposal,
25492646 & basic_review,
2550- & reviewed_commits ,
2647+ & review_commits ,
25512648 & images_paths,
25522649 ) ;
25532650
2554- assert_eq ! (
2555- markdown,
2556- r#"# Proposal 123
2651+ fn expected_markdown (
2652+ hashes_match : & str ,
2653+ all_reviewed_commits_match : & str ,
2654+ commits_matches : ( & str , & str ) ,
2655+ ) -> String {
2656+ format ! (
2657+ r#"# Proposal 123
25572658
25582659Vote: ADOPTED
2559- Hashes match: true
2560- All reviewed commits match their descriptions: false
2660+ Hashes match: {hashes_match}
2661+ All reviewed commits match their descriptions: {all_reviewed_commits_match}
25612662
25622663
25632664
@@ -2568,14 +2669,73 @@ Test summary
25682669
25692670Commits review:
25702671- **28111ed23**:
2571- Matches description: true
2672+ Matches description: {}
25722673 Comment: Good commit
25732674 Highlights: Feature A, Bug fix B
25742675- **47d98477c**:
2575- Matches description: false
2676+ Matches description: {}
25762677 Comment: Issues found
25772678 Highlights: Missing tests
2578- "#
2679+ "# ,
2680+ commits_matches. 0 , commits_matches. 1
2681+ )
2682+ }
2683+
2684+ assert_eq ! (
2685+ markdown,
2686+ expected_markdown( "true" , "false" , ( "true" , "false" ) )
2687+ ) ;
2688+
2689+ basic_review. build_reproduced = Some ( false ) ;
2690+ let markdown = proposal_review_summary_markdown (
2691+ & basic_proposal,
2692+ & basic_review,
2693+ & review_commits,
2694+ & images_paths,
2695+ ) ;
2696+ assert_eq ! (
2697+ markdown,
2698+ expected_markdown( "false" , "false" , ( "true" , "false" ) )
2699+ ) ;
2700+
2701+ basic_review. build_reproduced = None ;
2702+ let markdown = proposal_review_summary_markdown (
2703+ & basic_proposal,
2704+ & basic_review,
2705+ & review_commits,
2706+ & images_paths,
2707+ ) ;
2708+ assert_eq ! (
2709+ markdown,
2710+ expected_markdown( "Unanswered" , "false" , ( "true" , "false" ) )
2711+ ) ;
2712+
2713+ review_commits = some_reviewed_commits_not_answered ( ) ;
2714+ let markdown = proposal_review_summary_markdown (
2715+ & basic_proposal,
2716+ & basic_review,
2717+ & review_commits,
2718+ & images_paths,
2719+ ) ;
2720+ assert_eq ! (
2721+ markdown,
2722+ expected_markdown(
2723+ "Unanswered" ,
2724+ "Only partially answered (see individual reports below)" ,
2725+ ( "true" , "Unanswered" )
2726+ )
2727+ ) ;
2728+
2729+ review_commits = all_reviewed_commits_not_answered ( ) ;
2730+ let markdown = proposal_review_summary_markdown (
2731+ & basic_proposal,
2732+ & basic_review,
2733+ & review_commits,
2734+ & images_paths,
2735+ ) ;
2736+ assert_eq ! (
2737+ markdown,
2738+ expected_markdown( "Unanswered" , "Unanswered" , ( "Unanswered" , "Unanswered" ) )
25792739 ) ;
25802740 }
25812741}
0 commit comments