@@ -144,6 +144,11 @@ function ($attempts) use ($cachedDiff, $type): string {
144144 $ this ->output ->success ('Successfully generated and committed message. ' );
145145 }
146146
147+ public function schedule (Schedule $ schedule ): void
148+ {
149+ // $schedule->command(static::class)->everyMinute();
150+ }
151+
147152 /**
148153 * @codeCoverageIgnore
149154 * @psalm-suppress InvalidArgument
@@ -161,11 +166,6 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
161166 }
162167 }
163168
164- public function schedule (Schedule $ schedule ): void
165- {
166- // $schedule->command(static::class)->everyMinute();
167- }
168-
169169 /**
170170 * {@inheritDoc}
171171 */
@@ -274,32 +274,28 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
274274 }
275275 }
276276
277+ private function diffCommand (): array
278+ {
279+ return array_merge (['git ' , 'diff ' , '--cached ' ], $ this ->option ('diff-options ' ));
280+ }
281+
277282 /**
278- * @param null|mixed $input
283+ * @psalm-suppress RedundantCondition
279284 *
280285 * @noinspection CallableParameterUseCaseInTypeContextInspection
281286 */
282- private function createProcess (
283- array $ command ,
284- ?string $ cwd = null ,
285- ?array $ env = null ,
286- $ input = null ,
287- ?float $ timeout = 60
288- ): Process {
289- if (null === $ cwd ) {
290- $ cwd = $ this ->argument ('path ' );
291- }
292-
293- return tap (new Process ($ command , $ cwd , $ env , $ input , $ timeout ), function (Process $ process ): void {
294- if ($ this ->option ('verbose ' )) {
295- $ this ->output ->note ($ process ->getCommandLine ());
296- }
297- });
298- }
299-
300- private function diffCommand (): array
287+ private function commitCommandFor (Collection $ message ): array
301288 {
302- return array_merge (['git ' , 'diff ' , '--cached ' ], $ this ->option ('diff-options ' ));
289+ $ options = collect ($ this ->option ('commit-options ' ))
290+ ->when ($ this ->shouldntEdit (), static function (Collection $ collection ): Collection {
291+ return $ collection ->add ('--no-edit ' );
292+ })
293+ ->when ($ this ->shouldntVerify (), static function (Collection $ collection ): Collection {
294+ return $ collection ->add ('--no-verify ' );
295+ })
296+ ->all ();
297+
298+ return array_merge (['git ' , 'commit ' , '--message ' , $ this ->hydrateMessage ($ message )], $ options );
303299 }
304300
305301 private function promptFor (string $ cachedDiff , string $ type ): string
@@ -367,25 +363,6 @@ private function tryFixMessage(string $message): string
367363 );
368364 }
369365
370- /**
371- * @psalm-suppress RedundantCondition
372- *
373- * @noinspection CallableParameterUseCaseInTypeContextInspection
374- */
375- private function commitCommandFor (Collection $ message ): array
376- {
377- $ options = collect ($ this ->option ('commit-options ' ))
378- ->when ($ this ->shouldntEdit (), static function (Collection $ collection ): Collection {
379- return $ collection ->add ('--no-edit ' );
380- })
381- ->when ($ this ->shouldntVerify (), static function (Collection $ collection ): Collection {
382- return $ collection ->add ('--no-verify ' );
383- })
384- ->all ();
385-
386- return array_merge (['git ' , 'commit ' , '--message ' , $ this ->hydrateMessage ($ message )], $ options );
387- }
388-
389366 private function hydrateMessage (Collection $ message ): string
390367 {
391368 return $ message
@@ -398,6 +375,29 @@ private function hydrateMessage(Collection $message): string
398375 ->implode (str_repeat (PHP_EOL , 2 ));
399376 }
400377
378+ /**
379+ * @param null|mixed $input
380+ *
381+ * @noinspection CallableParameterUseCaseInTypeContextInspection
382+ */
383+ private function createProcess (
384+ array $ command ,
385+ ?string $ cwd = null ,
386+ ?array $ env = null ,
387+ $ input = null ,
388+ ?float $ timeout = 60
389+ ): Process {
390+ if (null === $ cwd ) {
391+ $ cwd = $ this ->argument ('path ' );
392+ }
393+
394+ return tap (new Process ($ command , $ cwd , $ env , $ input , $ timeout ), function (Process $ process ): void {
395+ if ($ this ->option ('verbose ' )) {
396+ $ this ->output ->note ($ process ->getCommandLine ());
397+ }
398+ });
399+ }
400+
401401 private function shouldntEdit (): bool
402402 {
403403 return ! Process::isTtySupported () || $ this ->option ('no-edit ' ) || $ this ->configManager ->get ('no_edit ' );
0 commit comments