@@ -73,16 +73,18 @@ public function handle(): int
73
73
throw new TaskException ('There are no cached files to commit. Try running `git add` to cache some files. ' );
74
74
}
75
75
76
+ $ type = $ this ->choice ('Please choice commit type ' , $ types = $ this ->configManager ->get ('types ' ), array_key_first ($ types ));
77
+
76
78
$ message = retry (
77
79
$ this ->option ('retry-times ' ),
78
- function ($ attempts ) use ($ cachedDiff ): string {
80
+ function ($ attempts ) use ($ cachedDiff, $ type ): string {
79
81
if ($ attempts > 1 ) {
80
82
$ this ->output ->note ('retrying... ' );
81
83
}
82
84
83
85
$ originalMessage = $ this ->generatorManager
84
86
->driver ($ this ->option ('generator ' ))
85
- ->generate ($ this ->getPrompt ($ cachedDiff ));
87
+ ->generate ($ this ->getPrompt ($ cachedDiff, $ type ));
86
88
$ message = $ this ->tryFixMessage ($ originalMessage );
87
89
if (! str ($ message )->jsonValidate ()) {
88
90
throw new TaskException (sprintf (
@@ -282,9 +284,17 @@ private function getDiffCommand(): array
282
284
return array_merge (['git ' , 'diff ' , '--cached ' ], $ this ->option ('diff-options ' ));
283
285
}
284
286
285
- private function getPrompt (string $ cachedDiff ): string
287
+ private function getPrompt (string $ cachedDiff, string $ type ): string
286
288
{
289
+ $ typePrompt = sprintf ($ this ->configManager ->get ('type_prompt ' ), $ type );
290
+ if (array_key_first ($ this ->configManager ->get ('types ' )) === $ type ) {
291
+ $ type = $ this ->configManager ->get ('type_mark ' );
292
+ $ typePrompt = '' ;
293
+ }
294
+
287
295
return (string ) str ($ this ->configManager ->get ("prompts. {$ this ->option ('prompt ' )}" ))
296
+ ->replace ($ this ->configManager ->get ('type_mark ' ), $ type )
297
+ ->replace ($ this ->configManager ->get ('type_prompt_mark ' ), $ typePrompt )
288
298
->replace ($ this ->configManager ->get ('diff_mark ' ), $ cachedDiff )
289
299
->when ($ this ->option ('verbose ' ), function (Stringable $ prompt ): Stringable {
290
300
$ this ->output ->note ((string ) $ prompt );
0 commit comments