@@ -217,7 +217,7 @@ ${hunks.old_hunk}
217
217
filename : string ,
218
218
file_content : string ,
219
219
file_diff : string
220
- ) : Promise < [ string , string ] | null > => {
220
+ ) : Promise < [ string , string , boolean ] | null > => {
221
221
const ins = inputs . clone ( )
222
222
if ( file_diff . length === 0 ) {
223
223
core . warning ( `summarize: file_diff is empty, skip ${ filename } ` )
@@ -226,6 +226,7 @@ ${hunks.old_hunk}
226
226
}
227
227
228
228
ins . filename = filename
229
+
229
230
// render prompt based on inputs so far
230
231
let tokens = tokenizer . get_token_count (
231
232
prompts . render_summarize_file_diff ( ins )
@@ -268,7 +269,24 @@ ${hunks.old_hunk}
268
269
summaries_failed . push ( `${ filename } (nothing obtained from openai)` )
269
270
return null
270
271
} else {
271
- return [ filename , summarize_resp ]
272
+ // parse the comment to look for complexity classification
273
+ // Format is : [COMPLEXITY]: <COMPLEX or SIMPLE>
274
+ // if the change is complex return true, else false
275
+ const complexityRegex = / \[ C O M P L E X I T Y \] : \s * ( C O M P L E X | S I M P L E ) /
276
+ const complexityMatch = summarize_resp . match ( complexityRegex )
277
+
278
+ if ( complexityMatch ) {
279
+ const complexity = complexityMatch [ 1 ]
280
+ const is_complex = complexity === 'COMPLEX' ? true : false
281
+
282
+ // remove this line from the comment
283
+ const summary = summarize_resp . replace ( complexityRegex , '' ) . trim ( )
284
+ core . info ( `filename: ${ filename } , complexity: ${ complexity } ` )
285
+ return [ filename , summary , is_complex ]
286
+ } else {
287
+ // Handle the case when the [COMPLEXITY] tag is not found
288
+ return [ filename , summarize_resp , true ]
289
+ }
272
290
}
273
291
} catch ( error ) {
274
292
core . warning ( `summarize: error from openai: ${ error } ` )
@@ -293,7 +311,7 @@ ${hunks.old_hunk}
293
311
294
312
const summaries = ( await Promise . all ( summaryPromises ) ) . filter (
295
313
summary => summary !== null
296
- ) as [ string , string ] [ ]
314
+ ) as [ string , string , boolean ] [ ]
297
315
298
316
if ( summaries . length > 0 ) {
299
317
// join summaries into one in the batches of 20
420
438
`
421
439
422
440
if ( options . summary_only !== true ) {
441
+ const files_and_changes_review = files_and_changes . filter ( ( [ filename ] ) => {
442
+ const is_complex =
443
+ summaries . find (
444
+ ( [ summaryFilename ] ) => summaryFilename === filename
445
+ ) ?. [ 2 ] ?? true
446
+ return is_complex
447
+ } )
448
+
449
+ const reviews_skipped = files_and_changes
450
+ . filter (
451
+ ( [ filename ] ) =>
452
+ ! files_and_changes_review . some (
453
+ ( [ reviewFilename ] ) => reviewFilename === filename
454
+ )
455
+ )
456
+ . map ( ( [ filename ] ) => filename )
457
+
423
458
// failed reviews array
424
459
const reviews_failed : string [ ] = [ ]
425
460
const do_review = async (
@@ -684,7 +719,12 @@ ${comment_chain}
684
719
}
685
720
686
721
const reviewPromises = [ ]
687
- for ( const [ filename , file_content , , patches ] of files_and_changes ) {
722
+ for ( const [
723
+ filename ,
724
+ file_content ,
725
+ ,
726
+ patches
727
+ ] of files_and_changes_review ) {
688
728
if ( options . max_files <= 0 || reviewPromises . length < options . max_files ) {
689
729
reviewPromises . push (
690
730
openai_concurrency_limit ( async ( ) =>
710
750
711
751
* ${ reviews_failed . join ( '\n* ' ) }
712
752
753
+ </details>
754
+ `
755
+ : ''
756
+ }
757
+
758
+ ${
759
+ reviews_skipped . length > 0
760
+ ? `<details>
761
+ <summary>Files not reviewed due to simple changes (${
762
+ reviews_skipped . length
763
+ } )</summary>
764
+
765
+ ### Skipped review
766
+
767
+ * ${ reviews_skipped . join ( '\n* ' ) }
768
+
713
769
</details>
714
770
`
715
771
: ''
0 commit comments