@@ -183,43 +183,45 @@ export const INIT_DIFF_PROMPT: OpenAI.Chat.Completions.ChatCompletionMessagePara
183
183
});`
184
184
} ;
185
185
186
- const getContent = ( translation : ConsistencyPrompt ) => {
187
- const getCommitString = ( commitWithScope : string , commitWithoutScope ?: string ) => {
188
- if ( config . OCO_OMIT_SCOPE && commitWithoutScope ) {
189
- return config . OCO_EMOJI
190
- ? `🐛 ${ removeConventionalCommitWord ( commitWithoutScope ) } `
191
- : commitWithoutScope ;
192
- }
193
- return config . OCO_EMOJI
194
- ? `🐛 ${ removeConventionalCommitWord ( commitWithScope ) } `
195
- : commitWithScope ;
196
- } ;
186
+ const COMMIT_TYPES = {
187
+ fix : '🐛' ,
188
+ feat : '✨'
189
+ } as const ;
197
190
198
- const fix = getCommitString (
199
- translation . commitFix ,
200
- translation . commitFixOmitScope
201
- ) ;
191
+ const generateCommitString = (
192
+ type : keyof typeof COMMIT_TYPES ,
193
+ message : string
194
+ ) : string => {
195
+ const cleanMessage = removeConventionalCommitWord ( message ) ;
196
+ return config . OCO_EMOJI
197
+ ? `${ COMMIT_TYPES [ type ] } ${ cleanMessage } `
198
+ : message ;
199
+ } ;
200
+
201
+ const getConsistencyContent = ( translation : ConsistencyPrompt ) => {
202
+ const fixMessage = config . OCO_OMIT_SCOPE && translation . commitFixOmitScope
203
+ ? translation . commitFixOmitScope
204
+ : translation . commitFix ;
205
+
206
+ const featMessage = config . OCO_OMIT_SCOPE && translation . commitFeatOmitScope
207
+ ? translation . commitFeatOmitScope
208
+ : translation . commitFeat ;
202
209
203
- const feat = config . OCO_OMIT_SCOPE && translation . commitFeatOmitScope
204
- ? ( config . OCO_EMOJI
205
- ? `✨ ${ removeConventionalCommitWord ( translation . commitFeatOmitScope ) } `
206
- : translation . commitFeatOmitScope )
207
- : ( config . OCO_EMOJI
208
- ? `✨ ${ removeConventionalCommitWord ( translation . commitFeat ) } `
209
- : translation . commitFeat ) ;
210
+ const fix = generateCommitString ( 'fix' , fixMessage ) ;
211
+ const feat = generateCommitString ( 'feat' , featMessage ) ;
210
212
211
213
const description = config . OCO_DESCRIPTION
212
214
? translation . commitDescription
213
215
: '' ;
214
216
215
- return ` ${ fix } \n ${ feat } \n ${ description } ` ;
217
+ return [ fix , feat , description ] . filter ( Boolean ) . join ( '\n' ) ;
216
218
} ;
217
219
218
220
const INIT_CONSISTENCY_PROMPT = (
219
221
translation : ConsistencyPrompt
220
222
) : OpenAI . Chat . Completions . ChatCompletionMessageParam => ( {
221
223
role : 'assistant' ,
222
- content : getContent ( translation )
224
+ content : getConsistencyContent ( translation )
223
225
} ) ;
224
226
225
227
export const getMainCommitPrompt = async (
0 commit comments