From 7fe46c51491d636000196aee72f0e6fba9f940d5 Mon Sep 17 00:00:00 2001 From: "ityaozm@gmail.com" Date: Thu, 16 Nov 2023 17:38:59 +0800 Subject: [PATCH] chore(commands): update CommitCommand.php - Add use Illuminate\Support\Str - Transform array body lines to bullet points --- app/Commands/CommitCommand.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Commands/CommitCommand.php b/app/Commands/CommitCommand.php index ae457f8..baeec2f 100644 --- a/app/Commands/CommitCommand.php +++ b/app/Commands/CommitCommand.php @@ -18,6 +18,7 @@ use App\Support\JsonFixer; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Support\Collection; +use Illuminate\Support\Str; use Illuminate\Support\Stringable; use LaravelZero\Framework\Commands\Command; use Symfony\Component\Console\Completion\CompletionInput; @@ -103,6 +104,16 @@ function ($attempts) use ($cachedDiff): string { $this->task('2. Choosing commit message', function () use (&$message, $messages): void { $message = collect(json_decode($messages, true, 512, JSON_THROW_ON_ERROR)) + ->transform(function (array $message): array { + if (\is_array($message['body'])) { + $message['body'] = collect($message['body']) + ->transform(static function (string $line): string { + return Str::start(trim($line, " \t\n\r\x0B"), '- '); + })->implode(PHP_EOL); + } + + return $message; + }) ->tap(function (Collection $messages): void { $this->newLine(2); $this->table(