@@ -33,6 +33,9 @@ async function gitStatus() {
3333 // git add the first file in the list of changes
3434 await execa ( 'git' , [ 'add' , filePaths [ 0 ] ] ) ;
3535 console . log ( `${ filePaths [ 0 ] } has been added to the staging area.` ) ;
36+ } else {
37+ console . log ( 'No changes to commit.' ) ;
38+ return false ;
3639 }
3740 } catch ( error ) {
3841 console . error ( error ) ;
@@ -60,20 +63,25 @@ async function generatePrompt() {
6063 // use the prompt from the config file emoji and send to openai
6164 const category = await openai . chat . completions . create ( {
6265 messages : [
63- { role : "system" , content : config . emoji } ,
64- { role : "user" , content : gitDiffContent } ,
66+ { role : "system" , content : config . emoji } ,
67+ { role : "user" , content : gitDiffContent } ,
6568 ] ,
66- model : "gpt-3.5-turbo"
69+ model : "gpt-3.5-turbo" ,
6770 } ) ;
6871 // use the prmopt from the config file message and send to openai
6972 const message = await openai . chat . completions . create ( {
7073 messages : [
71- { role : "system" , content : config . message } ,
72- { role : "user" , content : gitDiffContent } ,
74+ { role : "system" , content : config . message } ,
75+ { role : "user" , content : gitDiffContent } ,
7376 ] ,
74- model : "gpt-3.5-turbo"
77+ model : "gpt-3.5-turbo" ,
7578 } ) ;
76- return `${ category . choices [ 0 ] . message . content } : ${ message . choices [ 0 ] . message . content } ` ;
79+
80+ if ( await gitStatus ( ) !== false ) {
81+ return `${ category . choices [ 0 ] . message . content } : ${ message . choices [ 0 ] . message . content } ` ;
82+ } else {
83+ return false ;
84+ }
7785}
7886
7987export default generatePrompt ;
0 commit comments