@@ -190,12 +190,10 @@ impl RestClient {
190190 let has_changes = review_comments. full_patch . iter ( ) . any ( |p| !p. is_empty ( ) ) ;
191191 options. action = if feedback_inputs. passive_reviews {
192192 ReviewAction :: Comment
193+ } else if options. comments . is_empty ( ) && !has_changes {
194+ ReviewAction :: Approve
193195 } else {
194- if options. comments . is_empty ( ) && !has_changes {
195- ReviewAction :: Approve
196- } else {
197- ReviewAction :: RequestChanges
198- }
196+ ReviewAction :: RequestChanges
199197 } ;
200198 options. summary = review_comments. summarize ( & clang_versions, & options. comments ) ;
201199 self . client . post_pr_review ( & options) . await ?;
@@ -309,8 +307,8 @@ impl RestClient {
309307 files,
310308 & mut comment,
311309 format_checks_failed,
312- // tidy_version should be `Some()` value at this point.
313- & clang_versions. tidy_version . as_ref ( ) . unwrap ( ) . to_string ( ) ,
310+ // format_version should be `Some()` value at this point.
311+ & clang_versions. format_version . as_ref ( ) . unwrap ( ) . to_string ( ) ,
314312 & mut remaining_length,
315313 ) ;
316314 }
@@ -319,8 +317,8 @@ impl RestClient {
319317 files,
320318 & mut comment,
321319 tidy_checks_failed,
322- // format_version should be `Some()` value at this point.
323- & clang_versions. format_version . as_ref ( ) . unwrap ( ) . to_string ( ) ,
320+ // tidy_version should be `Some()` value at this point.
321+ & clang_versions. tidy_version . as_ref ( ) . unwrap ( ) . to_string ( ) ,
324322 & mut remaining_length,
325323 ) ;
326324 }
@@ -332,6 +330,9 @@ impl RestClient {
332330 }
333331}
334332
333+ /// A closing tag for details blocks in markdown comments.
334+ const CLOSER : & str = "\n </details>" ;
335+
335336fn make_format_comment (
336337 files : & [ Arc < Mutex < FileObj > > ] ,
337338 comment : & mut String ,
@@ -342,9 +343,8 @@ fn make_format_comment(
342343 let opener = format ! (
343344 "\n <details><summary>clang-format (v{version_used}) reports: <strong>{format_checks_failed} file(s) not formatted</strong></summary>\n \n " ,
344345 ) ;
345- let closer = String :: from ( "\n </details>" ) ;
346346 let mut format_comment = String :: new ( ) ;
347- * remaining_length -= opener. len ( ) as u64 + closer . len ( ) as u64 ;
347+ * remaining_length = remaining_length . saturating_sub ( opener. len ( ) as u64 + CLOSER . len ( ) as u64 ) ;
348348 for file in files {
349349 let file = file. lock ( ) . unwrap ( ) ;
350350 if let Some ( format_advice) = & file. format_advice
@@ -360,7 +360,7 @@ fn make_format_comment(
360360 }
361361 comment. push_str ( & opener) ;
362362 comment. push_str ( & format_comment) ;
363- comment. push_str ( & closer ) ;
363+ comment. push_str ( CLOSER ) ;
364364}
365365
366366fn make_tidy_comment (
@@ -373,9 +373,8 @@ fn make_tidy_comment(
373373 let opener = format ! (
374374 "\n <details><summary>clang-tidy (v{version_used}) reports: {tidy_checks_failed}<strong> concern(s)</strong></summary>\n \n "
375375 ) ;
376- let closer = String :: from ( "\n </details>" ) ;
377376 let mut tidy_comment = String :: new ( ) ;
378- * remaining_length -= opener. len ( ) as u64 + closer . len ( ) as u64 ;
377+ * remaining_length = remaining_length . saturating_sub ( opener. len ( ) as u64 + CLOSER . len ( ) as u64 ) ;
379378 for file in files {
380379 let file = file. lock ( ) . unwrap ( ) ;
381380 if let Some ( tidy_advice) = & file. tidy_advice {
@@ -409,7 +408,7 @@ fn make_tidy_comment(
409408 }
410409 comment. push_str ( & opener) ;
411410 comment. push_str ( & tidy_comment) ;
412- comment. push_str ( & closer ) ;
411+ comment. push_str ( CLOSER ) ;
413412}
414413
415414#[ cfg( all( test, feature = "bin" ) ) ]
0 commit comments