File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -532,10 +532,21 @@ export class AIProviderService implements Disposable {
532532 ) : Promise < AISummarizeResult | undefined > {
533533 const diff = await repo . git . diff ( ) . getDiff ?.( compareRef , baseRef ) ;
534534
535+ const log = await this . container . git . commits ( repo . path ) . getLog ( `${ baseRef } ..${ compareRef } ` ) ;
536+ const commits : [ string , number ] [ ] = [ ] ;
537+ for ( const [ _sha , commit ] of log ?. commits ?? [ ] ) {
538+ commits . push ( [ commit . message ?? '' , commit . date . getTime ( ) ] ) ;
539+ }
540+
541+ if ( ! diff ?. contents && ! commits . length ) {
542+ throw new Error ( 'No changes found to generate a pull request message from.' ) ;
543+ }
544+
535545 const result = await this . sendRequest (
536546 'generate-commitMessage' ,
537547 ( ) => ( {
538- diff : diff ?. contents ?? '[no code changes]' ,
548+ diff : diff ?. contents ?? '' ,
549+ data : commits . sort ( ( a , b ) => a [ 1 ] - b [ 1 ] ) . map ( c => c [ 0 ] ) ,
539550 context : options ?. context ?? '' ,
540551 instructions : configuration . get ( 'ai.generateCommitMessage.customInstructions' ) ?? '' ,
541552 } ) ,
You can’t perform that action at this time.
0 commit comments